* remove odf_utils-jar * test metadata in ParserTest git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6231 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
de4f0a006f
commit
67da20647f
Binary file not shown.
@ -0,0 +1,65 @@
|
||||
// ODContentHandler.java
|
||||
// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
||||
// first published 16.07.2007 on http://yacy.net
|
||||
//
|
||||
// This is a part of YaCy, a peer-to-peer based web search engine
|
||||
//
|
||||
// $LastChangedDate: 2009-07-09 22:13:11 +0200 (Do, 09. Jul 2009) $
|
||||
// $LastChangedRevision: 6186 $
|
||||
// $LastChangedBy: low012 $
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package de.anomic.document.parser.xml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* This is a SAX Handler, which handles the content.xml file
|
||||
* of an OpenDocument-file and passes all interesting data to
|
||||
* a Writer
|
||||
* @author f1ori
|
||||
*
|
||||
*/
|
||||
public class ODContentHandler extends DefaultHandler {
|
||||
private Writer out;
|
||||
public ODContentHandler(Writer out) {
|
||||
this.out = out;
|
||||
}
|
||||
@Override
|
||||
public void characters(final char ch[], final int start, final int length) {
|
||||
try {
|
||||
out.write(ch, start, length);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void endElement(final String uri, final String name, final String tag) {
|
||||
if ("text:p".equals(tag) || "table:table-row".equals(tag)) {
|
||||
// add newlines after paragraphs
|
||||
try {
|
||||
out.append("\n");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package de.anomic.document.parser.xml;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
public class ODMetaHandler extends DefaultHandler {
|
||||
private StringBuilder buffer = new StringBuilder();
|
||||
|
||||
private String docCreator = null;
|
||||
private String docLanguage = null;
|
||||
private String docKeyword = null;
|
||||
private String docSubject = null;
|
||||
private String docTitle = null;
|
||||
private String docDescription = null;
|
||||
|
||||
public ODMetaHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(final char ch[], final int start, final int length) {
|
||||
buffer.append(ch, start, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(final String uri, final String name, final String tag, final Attributes atts) throws SAXException {
|
||||
buffer.delete(0, buffer.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(final String uri, final String name, final String tag) {
|
||||
if ("dc:creator".equals(tag)) {
|
||||
this.docCreator = buffer.toString();
|
||||
} else if ("dc:language".equals(tag)) {
|
||||
this.docLanguage = buffer.toString();
|
||||
} else if ("meta:keyword".equals(tag)) {
|
||||
this.docKeyword = buffer.toString();
|
||||
} else if ("dc:subject".equals(tag)) {
|
||||
this.docSubject = buffer.toString();
|
||||
} else if ("dc:title".equals(tag)) {
|
||||
this.docTitle = buffer.toString();
|
||||
} else if ("dc:description".equals(tag)) {
|
||||
this.docDescription = buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
return docCreator;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return docLanguage;
|
||||
}
|
||||
public String getKeyword() {
|
||||
return docKeyword;
|
||||
}
|
||||
public String getSubject() {
|
||||
return docSubject;
|
||||
}
|
||||
public String getTitle() {
|
||||
return docTitle;
|
||||
}
|
||||
public String getDescription() {
|
||||
return docDescription;
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in new issue