xsddoc/src/net/sf/xframe/xsddoc Processor.java,1.32,1.33

Kurt Riede <[email protected]> Tue, 28 Dec 2004 10:52:25 +0000
Newsgroups gmane.text.xml.xframe.xsddoc.devel
Message-ID <[email protected]>
Update of /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14744/src/net/sf/xframe/xsddoc

Modified Files:
	Processor.java 
Log Message:
new attributes: proxyHost and proxyPort

Index: Processor.java
===================================================================
RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/Processor.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** Processor.java	15 Dec 2004 14:24:53 -0000	1.32
--- Processor.java	28 Dec 2004 10:52:22 -0000	1.33
***************
*** 204,207 ****
--- 204,213 ----
      private boolean hideGroups = false;
  
+     /** Optional name of proxy host. */
+     private String proxyHost;
+ 
+     /** Optional name of proxy port. */
+     private String proxyPort;
+ 
      /** Indicates if the processor is initialized. */
      private boolean initialized = false;
***************
*** 372,375 ****
--- 378,399 ----
  
      /**
+      * Setter method for proxyHost property.
+      *
+      * @param theProxyHost The proxyHost to set.
+      */
+     public void setProxyHost(final String theProxyHost) {
+         this.proxyHost = theProxyHost;
+     }
+ 
+     /**
+      * Setter method for proxyPort property.
+      *
+      * @param theProxyPort The proxyPort to set.
+      */
+     public void setProxyPort(final String theProxyPort) {
+         this.proxyPort = theProxyPort;
+     }
+ 
+     /**
       * Depending on xml attribute returns file extension for XML ro HTML files.
       *
***************
*** 390,394 ****
       */
      public void execute() throws ProcessorException {
!         if (this.out == null) {
              throw new ProcessorException("output folder is null");
          }
--- 414,418 ----
       */
      public void execute() throws ProcessorException {
!         if (out == null) {
              throw new ProcessorException("output folder is null");
          }
***************
*** 402,405 ****
--- 426,430 ----
          try {
              if (!initialized) {
+                 initProxy();
                  initBuilder();
                  initTransformers();
***************
*** 456,459 ****
--- 481,510 ----
  
      /**
+      * Initializes the proxy if defined.
+      */
+     private void initProxy() {
+         if (proxyHost != null) {
+             System.setProperty("http.proxySet", "true");
+             System.setProperty("http.proxyHost", proxyHost);
+             System.setProperty("http.proxyPort", proxyPort);
+         }
+     }
+ 
+     /**
+      * Initialise a namespace aware DocumentBuilder.
+      *
+      * @throws ParserConfigurationException if a DocumentBuilder
+      *         cannot be created.
+      */
+     private void initBuilder() throws ParserConfigurationException {
+         if (debug) {
+             System.out.println("create document builder");
+         }
+         builderFactory = DocumentBuilderFactory.newInstance();
+         builderFactory.setNamespaceAware(true);
+         builder = builderFactory.newDocumentBuilder();
+     }
+ 
+     /**
       * Initialises all needed transformers.
       *
***************
*** 478,496 ****
  
      /**
-      * Initialise a namespace aware DocumentBuilder.
-      *
-      * @throws ParserConfigurationException if a DocumentBuilder
-      *         cannot be created.
-      */
-     private void initBuilder() throws ParserConfigurationException {
-         if (debug) {
-             System.out.println("create document builder");
-         }
-         builderFactory = DocumentBuilderFactory.newInstance();
-         builderFactory.setNamespaceAware(true);
-         builder = builderFactory.newDocumentBuilder();
-     }
- 
-     /**
       * Creates a transformer for a given file name.
       *
--- 529,532 ----
***************
*** 1067,1076 ****
       */
      Document getDocument(final String systemId) throws SAXException, IOException {
          Document doc = (Document) schemaCache.get(systemId);
          if (doc == null) {
              doc = builder.parse(systemId);
!             final String targetNamespace = getTargetNamespace(doc);
!             if (targetNamespace != null && !"".equals(targetNamespace)) {
!                 schemaCache.put(systemId, doc);
              }
          }
--- 1103,1117 ----
       */
      Document getDocument(final String systemId) throws SAXException, IOException {
+         if (debug) {
+             System.out.println("getDocument: " + systemId);
+         }
          Document doc = (Document) schemaCache.get(systemId);
          if (doc == null) {
              doc = builder.parse(systemId);
!             if (doc != null) {
!                 final String targetNamespace = getTargetNamespace(doc);
!                 if (targetNamespace != null && !"".equals(targetNamespace)) {
!                     schemaCache.put(systemId, doc);
!                 }
              }
          }



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/