Author: adietish
Date: 2011-01-12 12:48:15 -0500 (Wed, 12 Jan 2011)
New Revision: 28139
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMUnmarshaller.java
Log:
added string-stripping (to remove \n,\t, " ", etc.)
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMUnmarshaller.java 2011-01-12
17:46:06 UTC (rev 28138)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMUnmarshaller.java 2011-01-12
17:48:15 UTC (rev 28139)
@@ -14,8 +14,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -30,13 +28,11 @@
/**
* @author André Dietisheim
- *
+ *
* @param <DELTACLOUDOBJECT>
*/
public abstract class AbstractDOMUnmarshaller<DELTACLOUDOBJECT> {
- private Pattern STRIP_REGEXP = Pattern.compile("[^\n \t]+");
-
private Class<DELTACLOUDOBJECT> type;
private String tagName;
@@ -45,7 +41,8 @@
this.tagName = tagName;
}
- public DELTACLOUDOBJECT unmarshall(InputStream inputStream, DELTACLOUDOBJECT
deltacloudObject) throws DeltaCloudClientException {
+ public DELTACLOUDOBJECT unmarshall(InputStream inputStream, DELTACLOUDOBJECT
deltacloudObject)
+ throws DeltaCloudClientException {
try {
Element element = getFirstElement(tagName, getDocument(inputStream));
if (element == null) {
@@ -60,7 +57,8 @@
}
- protected Document getDocument(InputStream inputStream) throws
ParserConfigurationException, SAXException, IOException {
+ protected Document getDocument(InputStream inputStream) throws
ParserConfigurationException, SAXException,
+ IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
return documentBuilder.parse(inputStream);
@@ -124,11 +122,7 @@
if (textContent == null || textContent.length() == 0) {
return textContent;
}
- Matcher matcher = STRIP_REGEXP.matcher(textContent);
- if (!matcher.matches()) {
- return null;
- }
- return matcher.group();
+ return textContent.trim();
}
}
Show replies by date