xsddoc/src/net/sf/xframe/xsddoc/util XMLUtil.java,1.4,1.5

Kurt Riede <[email protected]> Thu, 07 Oct 2004 22:53:21 +0000
Newsgroups gmane.text.xml.xframe.xsddoc.devel
Message-ID <[email protected]>
Update of /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24437/src/net/sf/xframe/xsddoc/util

Modified Files:
	XMLUtil.java 
Log Message:
minor refactoring

Index: XMLUtil.java
===================================================================
RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/util/XMLUtil.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** XMLUtil.java	20 Aug 2004 14:44:05 -0000	1.4
--- XMLUtil.java	7 Oct 2004 22:53:18 -0000	1.5
***************
*** 192,215 ****
       */
      public static String getLocallizedMessageAndLocation(final TransformerException e) {
!         final StringBuffer sbuffer = new StringBuffer();
          if (null != e.getLocator()) {
!             final String systemID = e.getLocator().getSystemId();
!             final int line = e.getLocator().getLineNumber();
!             final int column = e.getLocator().getColumnNumber();
!             if (null != systemID) {
!                 sbuffer.append(systemID);
!             }
!             if (0 != line) {
!                 sbuffer.append(":").append(line);
!             }
!             if (0 != column) {
!                 sbuffer.append(":").append(column);
!             }
          }
          final String message = e.getLocalizedMessage();
!         if (null != message) {
!             sbuffer.append(" ").append(message);
!         }
!         return sbuffer.toString();
      }
  
--- 192,205 ----
       */
      public static String getLocallizedMessageAndLocation(final TransformerException e) {
!         String systemID = null;
!         int line = 0;
!         int column = 0;
          if (null != e.getLocator()) {
!             systemID = e.getLocator().getSystemId();
!             line = e.getLocator().getLineNumber();
!             column = e.getLocator().getColumnNumber();
          }
          final String message = e.getLocalizedMessage();
!         return formaLocallizedMessageAndLocation(systemID, line, column, message);
      }
  
***************
*** 221,228 ****
       */
      public static String getLocallizedMessageAndLocation(final SAXParseException e) {
-         final StringBuffer sbuffer = new StringBuffer();
          final String systemID = e.getSystemId();
          final int line = e.getLineNumber();
          final int column = e.getColumnNumber();
          if (null != systemID) {
              sbuffer.append(systemID);
--- 211,233 ----
       */
      public static String getLocallizedMessageAndLocation(final SAXParseException e) {
          final String systemID = e.getSystemId();
          final int line = e.getLineNumber();
          final int column = e.getColumnNumber();
+         final String message = e.getLocalizedMessage();
+         return formaLocallizedMessageAndLocation(systemID, line, column, message);
+     }
+ 
+     /**
+      * Formats a message and a location into a locallized string.
+      *
+      * @param systemID the systemID of the file (optional)
+      * @param line the line number within the file (optional)
+      * @param column the column  number within the file (optional)
+      * @param message the message
+      * @return a locallized message string with location
+      */
+     private static String formaLocallizedMessageAndLocation(final String systemID,
+             final int line, final int column, final String message) {
+         final StringBuffer sbuffer = new StringBuffer();
          if (null != systemID) {
              sbuffer.append(systemID);
***************
*** 234,238 ****
              sbuffer.append(":").append(column);
          }
!         final String message = e.getLocalizedMessage();
          if (null != message) {
              sbuffer.append(" ").append(message);
--- 239,245 ----
              sbuffer.append(":").append(column);
          }
!         if (null != message) {
!             sbuffer.append(" ").append(message);
!         }
          if (null != message) {
              sbuffer.append(" ").append(message);



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl