Author: rgauss
Date: Tue Jun 11 03:26:33 2013
New Revision: 1491681
URL: http://svn.apache.org/r1491681
Log:
Fixed previous whitespace issues in separate commit for better readability of
diffs.
Modified:
tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/xml/ElementMetadataHandler.java
Modified:
tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/xml/ElementMetadataHandler.java
URL:
http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/xml/ElementMetadataHandler.java?rev=1491681&r1=1491680&r2=1491681&view=diff
==============================================================================
---
tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/xml/ElementMetadataHandler.java
(original)
+++
tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/xml/ElementMetadataHandler.java
Tue Jun 11 03:26:33 2013
@@ -31,15 +31,15 @@ import org.xml.sax.Attributes;
* @since Apache Tika 0.10
*/
public class ElementMetadataHandler extends AbstractMetadataHandler {
- /**
- * Logger for this class
- */
- private static final Log logger = LogFactory
- .getLog(ElementMetadataHandler.class);
-
- private static final String LOCAL_NAME_RDF_BAG = "Bag";
- private static final String LOCAL_NAME_RDF_LI = "li";
- private static final String URI_RDF =
"http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+ /**
+ * Logger for this class
+ */
+ private static final Log logger = LogFactory
+ .getLog(ElementMetadataHandler.class);
+
+ private static final String LOCAL_NAME_RDF_BAG = "Bag";
+ private static final String LOCAL_NAME_RDF_LI = "li";
+ private static final String URI_RDF =
"http://www.w3.org/1999/02/22-rdf-syntax-ns#";
private final String uri;
@@ -49,7 +49,7 @@ public class ElementMetadataHandler exte
private final String name;
private Property targetProperty;
-
+
private final boolean allowDuplicateValues;
private final boolean allowEmptyValues;
@@ -57,12 +57,12 @@ public class ElementMetadataHandler exte
* The buffer used to capture characters when inside a bag li element.
*/
private final StringBuilder bufferBagged = new StringBuilder();
-
+
/**
* The buffer used to capture characters inside standard elements.
*/
private final StringBuilder bufferBagless = new StringBuilder();
-
+
/**
* Whether or not the value was found in a standard element structure or
inside a bag.
*/
@@ -73,7 +73,7 @@ public class ElementMetadataHandler exte
/**
* Constructor for string metadata keys.
- *
+ *
* @param uri the uri of the namespace of the element
* @param localName the local name of the element
* @param metadata the Tika metadata object to populate
@@ -89,14 +89,14 @@ public class ElementMetadataHandler exte
this.allowDuplicateValues = false;
this.allowEmptyValues = false;
if (logger.isTraceEnabled()) {
- logger.trace("created simple handler for " + this.name);
- }
+ logger.trace("created simple handler for " + this.name);
+ }
}
-
+
/**
* Constructor for string metadata keys which allows change of behavior
* for duplicate and empty entry values.
- *
+ *
* @param uri the uri of the namespace of the element
* @param localName the local name of the element
* @param metadata the Tika metadata object to populate
@@ -120,7 +120,7 @@ public class ElementMetadataHandler exte
/**
* Constructor for Property metadata keys.
- *
+ *
* @param uri the uri of the namespace of the element
* @param localName the local name of the element
* @param metadata the Tika metadata object to populate
@@ -137,14 +137,14 @@ public class ElementMetadataHandler exte
this.allowDuplicateValues = false;
this.allowEmptyValues = false;
if (logger.isTraceEnabled()) {
- logger.trace("created property handler for " + this.name);
- }
+ logger.trace("created property handler for " + this.name);
+ }
}
-
+
/**
* Constructor for Property metadata keys which allows change of behavior
* for duplicate and empty entry values.
- *
+ *
* @param uri the uri of the namespace of the element
* @param localName the local name of the element
* @param metadata the Tika metadata object to populate
@@ -172,12 +172,12 @@ public class ElementMetadataHandler exte
}
protected boolean isMatchingElement(String uri, String localName) {
- // match if we're inside the parent element or within some bag element
+ // match if we're inside the parent element or within some bag element
return (uri.equals(this.uri) && localName.equals(this.localName)) ||
- (parentMatchLevel > 0 &&
- ((uri.equals(URI_RDF) &&
localName.equals(LOCAL_NAME_RDF_BAG)) ||
- (uri.equals(URI_RDF) &&
localName.equals(LOCAL_NAME_RDF_LI))
- )
+ (parentMatchLevel > 0 &&
+ ((uri.equals(URI_RDF) &&
localName.equals(LOCAL_NAME_RDF_BAG)) ||
+ (uri.equals(URI_RDF) &&
localName.equals(LOCAL_NAME_RDF_LI))
+ )
);
}
@@ -194,32 +194,32 @@ public class ElementMetadataHandler exte
@Override
public void endElement(String uri, String localName, String name) {
- if (isMatchingParentElement(uri, localName)) {
- parentMatchLevel--;
- }
+ if (isMatchingParentElement(uri, localName)) {
+ parentMatchLevel--;
+ }
if (isMatchingElement(uri, localName)) {
matchLevel--;
if (matchLevel == 2) {
- // we're inside a bag li element, add the bagged buffer
+ // we're inside a bag li element, add the bagged buffer
addMetadata(bufferBagged.toString().trim());
bufferBagged.setLength(0);
isBagless = false;
}
if (matchLevel == 0 && isBagless) {
- String valueBagless = bufferBagless.toString();
- if (valueBagless.length() > 0 &&
!valueBagless.contains(LOCAL_NAME_RDF_BAG)) {
- // we're in a standard element, add the bagless buffer
- addMetadata(valueBagless.trim());
- bufferBagless.setLength(0);
- }
- isBagless = true;
+ String valueBagless = bufferBagless.toString();
+ if (valueBagless.length() > 0 &&
!valueBagless.contains(LOCAL_NAME_RDF_BAG)) {
+ // we're in a standard element, add the bagless buffer
+ addMetadata(valueBagless.trim());
+ bufferBagless.setLength(0);
+ }
+ isBagless = true;
}
}
}
@Override
public void characters(char[] ch, int start, int length) {
- // We need to append to both buffers since we don't if we're inside a
bag until we're done
+ // We need to append to both buffers since we don't if we're inside a
bag until we're done
if (parentMatchLevel > 0 && matchLevel > 2) {
bufferBagged.append(ch, start, length);
}