You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2014/09/23 22:19:43 UTC

svn commit: r1627152 - /uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/Import_impl.java

Author: schor
Date: Tue Sep 23 20:19:42 2014
New Revision: 1627152

URL: http://svn.apache.org/r1627152
Log:
[UIMA-4020] redesign to make use of subtype classes for various alternative serialization techniques - plain, with indent and infoset support, and (separately) JSON.  As part of this remove no longer needed passing of contentHandler object through various calls.  As part of this, make various things public because the JSON support now in a separate project needs to reference these.

Modified:
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/Import_impl.java

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/Import_impl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/Import_impl.java?rev=1627152&r1=1627151&r2=1627152&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/Import_impl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/Import_impl.java Tue Sep 23 20:19:42 2014
@@ -144,13 +144,31 @@ public class Import_impl extends MetaDat
     }
   }
 
+  
   /**
    * Overridden to provide custom XML representation.
    * 
    * @see org.apache.uima.util.XMLizable#toXML(ContentHandler)
    */
-  public void toXML(ContentHandler aContentHandler, boolean aWriteDefaultNamespaceAttribute)
+  
+  public void toXML(ContentHandler aContentHandler, boolean aWriteDefaultNamespaceAttribute) throws SAXException {
+    if (null == serialContext.get()) {
+      getSerialContext(aContentHandler);  
+      try {
+        toXMLinner(aWriteDefaultNamespaceAttribute);
+      } finally {
+        serialContext.remove();
+      }
+    } else {
+      toXMLinner(aWriteDefaultNamespaceAttribute);
+    }
+  }
+  
+  private void toXMLinner(boolean aWriteDefaultNamespaceAttribute)
           throws SAXException {
+    SerialContext sc = serialContext.get();
+    Serializer serializer = sc.serializer;   
+    
     String namespace = getXmlizationInfo().namespace;
     AttributesImpl attrs = new AttributesImpl();
     if (getName() != null) {
@@ -159,10 +177,10 @@ public class Import_impl extends MetaDat
     if (getLocation() != null) {
       attrs.addAttribute("", "location", "location", null, getLocation());
     }
-    Node node = findMatchingSubElement(aContentHandler, "import");
-    outputStartElement(aContentHandler, node, namespace, "import", "import", attrs);
+    Node node = serializer.findMatchingSubElement("import");
+    serializer.outputStartElement(node, namespace, "import", "import", attrs);
 //    aContentHandler.startElement(getXmlizationInfo().namespace, "import", "import", attrs);
-    outputEndElement(aContentHandler, node, namespace, "import", "import");
+    serializer.outputEndElement(node, namespace, "import", "import");
 //    aContentHandler.endElement(getXmlizationInfo().namespace, "import", "import");
   }