Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r163 - trunk/src/ise/antelope/common/SAXNodeHandler.java

antelope
Discussion topic

Back to topic list

svn commit: r163 - trunk/src/ise/antelope/common/SAXNodeHandler.java

Author danson
Full name Dale Anson
Date 2009-05-18 05:37:54 PDT
Message Author: danson
Date: 2009-05-18 05:37:54-0700
New Revision: 163

Modified:
   trunk/src/ise/antelo​pe/common/SAXNodeHan​dler.java

Log:
Fix for Issue 47, loading property task throws error on refid attribute.

Modified: trunk/src/ise/antelo​pe/common/SAXNodeHan​dler.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/src/​ise/antelope/common/​SAXNodeHandler.java?​view=diff&pathre​v=163&r1=162​&r2=163
====================​====================​====================​==================
--- trunk/src/ise/antelo​pe/common/SAXNodeHan​dler.java (original)
+++ trunk/src/ise/antelo​pe/common/SAXNodeHan​dler.java 2009-05-18 05:37:54-0700
@@ -6,7 +6,6 @@
 import java.util.logging.*;
 import java.util.regex.*;
 import javax.swing.JOptionPane;
-import javax.swing.tree.Def​aultTreeModel;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SA​XParserFactory;
 
@@ -49,20 +48,20 @@
     // holds properties found while parsing the file
     private HashMap antProperties = new HashMap();
 
- private Logger _logger = Logger.getLogger("is​e.antelope.Antelope"​);
+ //private Logger _logger = Logger.getLogger( "ise.antelope.Antelope" );
 
     // need to update occassionally as new versions of Ant are released.
     // these lists are from Ant 1.7.0.
     // -- shouldn't need these any longer, the lists are now loaded from the default.properties
     // files from Ant itself, see the init() method.
- private List default_taskList = Arrays.asList(new String[]{"ant", "antcall", "antstructure", "apply", "available", "basename", "buildnumber", "bunzip2", "bzip2", "checksum", "chmod", "classloader", "concat", "condition", "copy", "cvs", "cvschangelog", "cvspass", "cvstagdiff", "cvsversion", "defaultexcludes", "delete", "dependset", "diagnostics", "dirname", "ear", "echo", "exec", "fail", "filter", "fixcrlf", "genkey", "get", "gunzip", "gzip", "import", "input", "jar", "java", "javac", "javadoc", "length", "loadfile", "loadproperties", "loadresource", "macrodef", "mail", "manifest", "manifestclasspath", "mkdir", "move", "nice", "parallel", "patch", "pathconvert", "presetdef", "property", "record", "replace", "rmic", "sequential", "signjar", "sleep", "sql", "subant", "sync", "tar", "taskdef", "tempfile", "touch", "tstamp", "typedef", "unjar", "untar", "unwar", "unzip", "uptodate", "waitfor", "war", "whichresource", "xmlproperty", "xslt", "zip", "antlr", "apt", "attrib", "bl
 genclient", "cab", "cccheckin", "cccheckout", "cclock", "ccmcheckin", "ccmcheckintask", "ccmcheckout", "ccmcreatetask", "ccmkattr", "ccmkbl", "ccmkdir", "ccmkelem", "ccmklabel", "ccmklbtype", "ccmreconfigure", "ccrmtype", "ccuncheckout", "ccunlock", "ccupdate", "chgrp", "chown", "csc", "ddcreator", "depend", "echoproperties", "echoxml", "ejbc", "ejbjar", "ftp", "ilasm", "ildasm", "image", "importtypelib", "iplanet-ejbc", "jarlib-available", "jarlib-display", "jarlib-manifest", "jarlib-resolve", "javacc", "javah", "jdepend", "jjdoc", "jjtree", "jsharpc", "jspc", "junit", "junitreport", "makeurl", "native2ascii", "netrexxc", "p4add", "p4change", "p4counter", "p4delete", "p4edit", "p4fstat", "p4have", "p4integrate", "p4label", "p4labelsync", "p4reopen", "p4resolve", "p4revert", "p4submit", "p4sync", "propertyfile", "pvcs", "replaceregexp", "resourcecount", "rexec", "rpm", "schemavalidate", "scp", "script", "scriptdef", "serverdeploy", "setproxy", "soscheckin", "soscheckout", "s
 osget", "soslabel", "sound", "splash", "sshexec", "stcheckin", "stcheckout", "stlabel", "stlist", "stylebook", "symlink", "telnet", "translate", "vbc", "verifyjar", "vssadd", "vsscheckin", "vsscheckout", "vsscp", "vsscreate", "vssget", "vsshistory", "vsslabel", "wljspc", "wlrun", "wlstop", "wsdltodotnet", "xmlvalidate", "copydir", "copyfile", "copypath", "deltree", "execon", "javadoc2", "jlink", "mimemail", "rename", "renameext", "starteam", "style", "WsdlToDotnet"});
- private List default_typeList = Arrays.asList(new String[]{"description", "filterchain", "filterreader", "filterset", "mapper", "redirector", "patternset", "regexp", "substitution", "xmlcatalog", "extensionSet", "extension", "selector", "signedselector", "scriptfilter", "assertions", "concatfilter", "mavenrepository", "scriptselector", "scriptmapper", "identitymapper", "flattenmapper", "globmapper", "mergemapper", "regexpmapper", "packagemapper", "unpackagemapper", "compositemapper", "chainedmapper", "filtermapper", "isfileselected", "scriptcondition", "dirset", "filelist", "fileset", "path", "propertyset", "zipfileset", "classfileset", "libfileset", "files", "restrict", "union", "difference", "intersect", "sort", "resources", "first", "tarfileset", "tokens", "resource", "file", "url", "string", "zipentry", "propertyresource", "tarentry", "gzipresource", "bzip2resource", "javaresource", "linetokenizer", "stringtokenizer", "filetokenizer"});
+ private List default_taskList = Arrays.asList( new String[] {"ant", "antcall", "antstructure", "apply", "available", "basename", "buildnumber", "bunzip2", "bzip2", "checksum", "chmod", "classloader", "concat", "condition", "copy", "cvs", "cvschangelog", "cvspass", "cvstagdiff", "cvsversion", "defaultexcludes", "delete", "dependset", "diagnostics", "dirname", "ear", "echo", "exec", "fail", "filter", "fixcrlf", "genkey", "get", "gunzip", "gzip", "import", "input", "jar", "java", "javac", "javadoc", "length", "loadfile", "loadproperties", "loadresource", "macrodef", "mail", "manifest", "manifestclasspath", "mkdir", "move", "nice", "parallel", "patch", "pathconvert", "presetdef", "property", "record", "replace", "rmic", "sequential", "signjar", "sleep", "sql", "subant", "sync", "tar", "taskdef", "tempfile", "touch", "tstamp", "typedef", "unjar", "untar", "unwar", "unzip", "uptodate", "waitfor", "war", "whichresource", "xmlproperty", "xslt", "zip", "antlr", "apt", "attrib", "
 blgenclient", "cab", "cccheckin", "cccheckout", "cclock", "ccmcheckin", "ccmcheckintask", "ccmcheckout", "ccmcreatetask", "ccmkattr", "ccmkbl", "ccmkdir", "ccmkelem", "ccmklabel", "ccmklbtype", "ccmreconfigure", "ccrmtype", "ccuncheckout", "ccunlock", "ccupdate", "chgrp", "chown", "csc", "ddcreator", "depend", "echoproperties", "echoxml", "ejbc", "ejbjar", "ftp", "ilasm", "ildasm", "image", "importtypelib", "iplanet-ejbc", "jarlib-available", "jarlib-display", "jarlib-manifest", "jarlib-resolve", "javacc", "javah", "jdepend", "jjdoc", "jjtree", "jsharpc", "jspc", "junit", "junitreport", "makeurl", "native2ascii", "netrexxc", "p4add", "p4change", "p4counter", "p4delete", "p4edit", "p4fstat", "p4have", "p4integrate", "p4label", "p4labelsync", "p4reopen", "p4resolve", "p4revert", "p4submit", "p4sync", "propertyfile", "pvcs", "replaceregexp", "resourcecount", "rexec", "rpm", "schemavalidate", "scp", "script", "scriptdef", "serverdeploy", "setproxy", "soscheckin", "soscheckout",
 "sosget", "soslabel", "sound", "splash", "sshexec", "stcheckin", "stcheckout", "stlabel", "stlist", "stylebook", "symlink", "telnet", "translate", "vbc", "verifyjar", "vssadd", "vsscheckin", "vsscheckout", "vsscp", "vsscreate", "vssget", "vsshistory", "vsslabel", "wljspc", "wlrun", "wlstop", "wsdltodotnet", "xmlvalidate", "copydir", "copyfile", "copypath", "deltree", "execon", "javadoc2", "jlink", "mimemail", "rename", "renameext", "starteam", "style", "WsdlToDotnet"} );
+ private List default_typeList = Arrays.asList( new String[] {"description", "filterchain", "filterreader", "filterset", "mapper", "redirector", "patternset", "regexp", "substitution", "xmlcatalog", "extensionSet", "extension", "selector", "signedselector", "scriptfilter", "assertions", "concatfilter", "mavenrepository", "scriptselector", "scriptmapper", "identitymapper", "flattenmapper", "globmapper", "mergemapper", "regexpmapper", "packagemapper", "unpackagemapper", "compositemapper", "chainedmapper", "filtermapper", "isfileselected", "scriptcondition", "dirset", "filelist", "fileset", "path", "propertyset", "zipfileset", "classfileset", "libfileset", "files", "restrict", "union", "difference", "intersect", "sort", "resources", "first", "tarfileset", "tokens", "resource", "file", "url", "string", "zipentry", "propertyresource", "tarentry", "gzipresource", "bzip2resource", "javaresource", "linetokenizer", "stringtokenizer", "filetokenizer"} );
     private List taskList = default_taskList;
     private List typeList = default_typeList;
 
     /** Constructor */
     public SAXNodeHandler() {
- this(null);
+ this( null );
     }
 
     /**
@@ -70,8 +69,8 @@
      *
      * @param in the source file
      */
- public SAXNodeHandler(File in) {
- this(in, false);
+ public SAXNodeHandler( File in ) {
+ this( in, false );
     }
 
     /**
@@ -80,7 +79,7 @@
      * @param in
      * @param imported
      */
- public SAXNodeHandler(File in, boolean imported) {
+ public SAXNodeHandler( File in, boolean imported ) {
         infile = in;
         isImported = imported;
         init();
@@ -91,19 +90,19 @@
         // not as a plugin. Maybe a jEdit classloader issue???
         try {
             Properties p = new Properties();
- p.load(getClass().ge​tClassLoader().getRe​sourceAsStream("org/​apache/tools/ant/tas​kdefs/defaults.prope​rties"));
- taskList = Collections.list(p.p​ropertyNames());
+ p.load( getClass().getClassL​oader().getResourceA​sStream( "org/apache/tools/an​t/taskdefs/defaults.​properties" ) );
+ taskList = Collections.list( p.propertyNames() );
         }
- catch(Exception e) {
+ catch ( Exception e ) {
             //System.out.println("Error loading Ant task list, using defaults.");
             taskList = default_taskList;
         }
         try {
             Properties p = new Properties();
- p.load(getClass().ge​tClassLoader().getRe​sourceAsStream("org/​apache/tools/ant/typ​es/defaults.properti​es"));
- typeList = Collections.list(p.p​ropertyNames());
+ p.load( getClass().getClassL​oader().getResourceA​sStream( "org/apache/tools/an​t/types/defaults.pro​perties" ) );
+ typeList = Collections.list( p.propertyNames() );
         }
- catch(Exception e) {
+ catch ( Exception e ) {
             //System.out.println("Error loading Ant type list, using defaults.");
             typeList = default_typeList;
         }
@@ -114,7 +113,7 @@
      *
      * @param locator The new locator value
      */
- public void setDocumentLocator(Locator locator) {
+ public void setDocumentLocator( Locator locator ) {
         this.locator = locator;
     }
 
@@ -131,7 +130,7 @@
 
     /** Description of the Method */
     public void startDocument() {
- docLocator = new LocatorImpl(locator);
+ docLocator = new LocatorImpl( locator );
     }
 
 
@@ -144,50 +143,50 @@
      * @param attributes Description of the Parameter
      * @exception SAXException Description of the Exception
      */
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ public void startElement( String uri, String localName, String qName, Attributes attributes ) throws SAXException {
         //System.out.println("qName = " + qName);
         try {
- Locator l = new LocatorImpl(locator);
- SAXTreeNode child = new SAXTreeNode(qName, new Point(l.getLineNumber(), l.getColumnNumber()), attributes);
- child.setImported(isImported);
+ Locator l = new LocatorImpl( locator );
+ SAXTreeNode child = new SAXTreeNode( qName, new Point( l.getLineNumber(), l.getColumnNumber() ), attributes );
+ child.setImported( isImported );
 
             // maybe mark this element as a project, target, task, or type
- setKind(qName, child);
+ setKind( qName, child );
 
             // set the source file for the node. Elements from included files will
             // have a systemId set, elements in the base file will not, nor will
             // imported files.
             /// might need to deal with http as well as file
- if (l.getSystemId() != null && l.getSystemId().star​tsWith("file:")) {
+ if ( l.getSystemId() != null && l.getSystemId().startsWith( "file:" ) ) {
                 String sid = l.getSystemId();
- if (sid.startsWith("file:"))
- sid = sid.substring("file:​".length());
- File f = new File(sid);
- if (!f.exists() && infile != null) {
+ if ( sid.startsWith( "file:" ) )
+ sid = sid.substring( "file:".length() );
+ File f = new File( sid );
+ if ( !f.exists() && infile != null ) {
                     File dir = infile;
- if (!dir.isDirectory())
+ if ( !dir.isDirectory() )
                         dir = dir.getParentFile();
- f = new File(dir, f.getName());
+ f = new File( dir, f.getName() );
                 }
- child.setFile(f);
+ child.setFile( f );
             }
- else if (infile != null) {
- child.setFile(infile);
+ else if ( infile != null ) {
+ child.setFile( infile );
             }
 
             // for the <import> task, load the imported file
- if (qName.equals("import")) {
+ if ( qName.equals( "import" ) ) {
                 // verify the imported file exists
- int index = attributes.getIndex("file");
- if (index > -1) {
- String filename = attributes.getValue(index);
- filename = resolveValue(filename);
+ int index = attributes.getIndex( "file" );
+ if ( index > -1 ) {
+ String filename = attributes.getValue( index );
+ filename = resolveValue( filename );
                     //System.out.println("filename = " + filename);
- File f = new File(filename);
- if (!f.exists()) {
- f = new File(infile.getParent(), filename);
+ File f = new File( filename );
+ if ( !f.exists() ) {
+ f = new File( infile.getParent(), filename );
                     }
- if (f.exists()) {
+ if ( f.exists() ) {
                         try {
                             // stash the current settings
                             SAXTreeNode old_root = getRoot();
@@ -201,10 +200,10 @@
                             isImported = true;
 
                             // do the import
- InputSource source = new InputSource(new FileReader(f));
+ InputSource source = new InputSource( new FileReader( f ) );
                             SAXParser parser = SAXParserFactory.new​Instance().newSAXPar​ser();
- SAXNodeHandler handler = new SAXNodeHandler(f, true);
- parser.parse(source, handler);
+ SAXNodeHandler handler = new SAXNodeHandler( f, true );
+ parser.parse( source, handler );
                             child = handler.getRoot();
 
                             // restore the previous settings
@@ -214,15 +213,15 @@
                             infile = old_infile;
                             isImported = old_is_imported;
                         }
- catch (Exception e) {
+ catch ( Exception e ) {
                             StringBuffer sb = new StringBuffer();
- sb.append("<html>Error loading imported file: ").append(f.getAbsol​utePath()).append("​<br>");
- sb.append("at line number: ").append(l.getLineN​umber()).append(", col number: ").append(l.getColum​nNumber()).append("​<p>");
- sb.append("The specific error is: ").append(e.getMessa​ge()).append("<p​>");
- sb.append("Do you want to load the rest of the file?");
- int rtn = JOptionPane.showConf​irmDialog(null, sb.toString(), "Error loading build file", JOptionPane.ERROR_MESSAGE);
- if (rtn == JOptionPane.NO_OPTION)
- throw new SAXException(e);
+ sb.append( "<html>Error loading imported file: " ).append( f.getAbsolutePath() ).append( "<br>" );
+ sb.append( "at line number: " ).append( l.getLineNumber() ).append( ", col number: " ).append( l.getColumnNumber() ).append( "<p>" );
+ sb.append( "The specific error is: " ).append( e.getMessage() ).append( "<p>" );
+ sb.append( "Do you want to load the rest of the file?" );
+ int rtn = JOptionPane.showConfirmDialog( null, sb.toString(), "Error loading build file", JOptionPane.ERROR_MESSAGE );
+ if ( rtn == JOptionPane.NO_OPTION )
+ throw new SAXException( e );
                         }
                     }
                     ///
@@ -230,45 +229,45 @@
             }
 
             // load and resolve properties
- if (qName.equals("property")) {
+ if ( qName.equals( "property" ) ) {
                 String value = null;
- if (child.getAttributeV​alue("name") != null) {
- String name = child.getAttributeVa​lue("name");
- if (child.getAttributeV​alue("value") != null) {
- value = child.getAttributeVa​lue("value");
- }
- else if (child.getAttributeV​alue("location") != null) {
- value = child.getAttributeVa​lue("location");
- }
- value = resolveValue(value);
- if (value != null) {
- antProperties.put(name, value);
+ if ( child.getAttributeValue( "name" ) != null ) {
+ String name = child.getAttributeValue( "name" );
+ if ( child.getAttributeValue( "value" ) != null ) {
+ value = child.getAttributeValue( "value" );
+ }
+ else if ( child.getAttributeValue( "location" ) != null ) {
+ value = child.getAttributeValue( "location" );
+ }
+ value = resolveValue( value );
+ if ( value != null ) {
+ antProperties.put( name, value );
                     }
                 }
                 /// maybe shouldn't do the 'else'?
- else if (child.getAttributeV​alue("file") != null) {
- String filename = child.getAttributeVa​lue("file");
- filename = resolveValue(filename);
- File f = new File(filename);
- if (!f.exists()) {
- f = new File(infile.getParent(), filename);
+ else if ( child.getAttributeValue( "file" ) != null ) {
+ String filename = child.getAttributeValue( "file" );
+ filename = resolveValue( filename );
+ File f = new File( filename );
+ if ( !f.exists() ) {
+ f = new File( infile.getParent(), filename );
                     }
                     //System.out.println("+++++ property filename: " + f);
- if (f.exists()) {
+ if ( f.exists() ) {
                         Properties props = new Properties();
                         try {
- props.load(new FileInputStream(f));
+ props.load( new FileInputStream( f ) );
                         }
- catch(Exception e) {
+ catch ( Exception e ) {
                             e.printStackTrace();
                         }
                         Enumeration en = props.propertyNames();
- while(en.hasMoreElements()) {
- String name = (String)en.nextElement();
- value = props.getProperty(name);
- value = resolveValue(value);
- if (value != null) {
- antProperties.put(name, value);
+ while ( en.hasMoreElements() ) {
+ String name = ( String ) en.nextElement();
+ value = props.getProperty( name );
+ value = resolveValue( value );
+ if ( value != null ) {
+ antProperties.put( name, value );
                             }
                         }
                     }
@@ -276,60 +275,63 @@
             }
 
             // maybe store some dependant property files
- if (qName.equals("property") && child.getAttributeValue("file") != null) {
- addPropertyFile(child, "file");
+ if ( qName.equals( "property" ) && child.getAttributeValue( "file" ) != null ) {
+ addPropertyFile( child, "file" );
             }
- else if (qName.equals("loadproperties") && child.getAttributeVa​lue("srcfile") != null) {
- addPropertyFile(child, "srcfile");
+ else if ( qName.equals( "loadproperties" ) && child.getAttributeValue( "srcfile" ) != null ) {
+ addPropertyFile( child, "srcfile" );
             }
 
             // add the child to the parent node
- if (stack.empty()) {
+ if ( stack.empty() ) {
                 rootNode = child;
             }
             else {
- SAXTreeNode parent = (SAXTreeNode) stack.peek();
- parent.add(child);
+ SAXTreeNode parent = ( SAXTreeNode ) stack.peek();
+ parent.add( child );
                 // check if this node is the default target for the build file
- if (child.isTarget()) {
- String default_target = parent.getAttributeV​alue("default");
- String child_target = child.getAttributeVa​lue("name");
- if (default_target != null && child_target != null && default_target.equal​s(child_target)) {
- child.setDefaultTarget(true);
+ if ( child.isTarget() ) {
+ String default_target = parent.getAttributeValue( "default" );
+ String child_target = child.getAttributeValue( "name" );
+ if ( default_target != null && child_target != null && default_target.equals( child_target ) ) {
+ child.setDefaultTarget( true );
                     }
                 }
             }
 
- stack.push(child);
+ stack.push( child );
         }
- catch (SAXException se) {
+ catch ( SAXException se ) {
             StringBuffer sb = new StringBuffer();
- sb.append("<html>Error loading build file ");
- sb.append("at line number: ").append(locator.ge​tLineNumber()).appen​d(", col number: ").append(locator.ge​tColumnNumber()).app​end("<p>");
- sb.append("The specific error is: ").append(se.getMess​age()).append("<p​>");
- throw new SAXException(sb.toString());
+ sb.append( "<html>Error loading build file " );
+ sb.append( "at line number: " ).append( locator.getLineNumber() ).append( ", col number: " ).append( locator.getColumnNumber() ).append( "<p>" );
+ sb.append( "The specific error is: " ).append( se.getMessage() ).append( "<p>" );
+ throw new SAXException( sb.toString() );
         }
     }
 
- private String resolveValue(String s) {
+ private String resolveValue( String s ) {
+ if ( s == null ) {
+ return null;
+ }
         StringBuffer output = new StringBuffer();
         String regex = "\\$\\{.*?\\}";
- Pattern p = Pattern.compile(regex);
- Matcher m = p.matcher(s);
+ Pattern p = Pattern.compile( regex );
+ Matcher m = p.matcher( s );
         int i = 0;
- while (m.find(i)) {
+ while ( m.find( i ) ) {
             int start = m.start();
             int end = m.end();
- output.append(s.substring(i, start));
- String name = s.substring(start + 2, end - 1);
- String value = (String)antPropertie​s.get(name);
- if (value == null)
- value = System.getProperty(name);
+ output.append( s.substring( i, start ) );
+ String name = s.substring( start + 2, end - 1 );
+ String value = ( String ) antProperties.get( name );
+ if ( value == null )
+ value = System.getProperty( name );
             //System.out.println("+++++ name: " + name + ", value: " + value);
- output.append(value == null ? "${" + name + "}" : value);
+ output.append( value == null ? "${" + name + "}" : value );
             i = end;
         }
- return ( output.toString() + s.substring(i));
+ return ( output.toString() + s.substring( i ) );
     }
 
 
@@ -341,7 +343,7 @@
      * @param qName Description of the Parameter
      * @exception SAXException Description of the Exception
      */
- public void endElement(String uri, String localName, String qName) throws SAXException {
+ public void endElement( String uri, String localName, String qName ) throws SAXException {
         stack.pop();
     }
 
@@ -353,88 +355,88 @@
      * @param systemId the systemId
      * @return an InputSource
      */
- public InputSource resolveEntity(String publicId, String systemId) {
- if (systemId != null) {
- if (systemId.toLowerCas​e().startsWith("http​")) {
+ public InputSource resolveEntity( String publicId, String systemId ) {
+ if ( systemId != null ) {
+ if ( systemId.toLowerCase​().startsWith( "http" ) ) {
                 try {
- InputSource is = new InputSource(new java.net.URL(systemI​d).openStream());
- is.setPublicId(publicId);
- is.setSystemId(systemId);
+ InputSource is = new InputSource( new java.net.URL( systemId ).openStream() );
+ is.setPublicId( publicId );
+ is.setSystemId( systemId );
                     return is;
                 }
- catch (Exception e) {
+ catch ( Exception e ) {
                     StringBuffer sb = new StringBuffer();
- sb.append("<html>Error loading included resource: ").append(systemId).​append("<br>")​;
- sb.append("at line number: ").append(locator.ge​tLineNumber()).appen​d(", col number: ").append(locator.ge​tColumnNumber()).app​end("<p>");
- sb.append("The specific error is: ").append(e.getMessa​ge()).append("<p​>");
- sb.append("Do you want to load the rest of the file?");
- int rtn = JOptionPane.showConf​irmDialog(null, sb.toString(), "Error loading build file", JOptionPane.ERROR_MESSAGE);
- if (rtn == JOptionPane.NO_OPTION)
- throw new RuntimeException(e);
+ sb.append( "<html>Error loading included resource: " ).append( systemId ).append( "<br>" );
+ sb.append( "at line number: " ).append( locator.getLineNumber() ).append( ", col number: " ).append( locator.getColumnNumber() ).append( "<p>" );
+ sb.append( "The specific error is: " ).append( e.getMessage() ).append( "<p>" );
+ sb.append( "Do you want to load the rest of the file?" );
+ int rtn = JOptionPane.showConfirmDialog( null, sb.toString(), "Error loading build file", JOptionPane.ERROR_MESSAGE );
+ if ( rtn == JOptionPane.NO_OPTION )
+ throw new RuntimeException( e );
                     return null;
                 }
             }
             else {
- String sid = new String(systemId);
- if (sid.startsWith("file:"))
- sid = sid.substring("file:​".length());
+ String sid = new String( systemId );
+ if ( sid.startsWith( "file:" ) )
+ sid = sid.substring( "file:".length() );
                 File f;
- if (sid.startsWith("..")) {
+ if ( sid.startsWith( ".." ) ) {
                     // handle relative paths
- if (infile == null)
+ if ( infile == null )
                         return null;
- if (!infile.isDirectory())
- f = new File(infile.getParen​tFile().getParentFil​e(), sid.substring(2));
+ if ( !infile.isDirectory() )
+ f = new File( infile.getParentFile​().getParentFile(), sid.substring( 2 ) );
                     else
- f = new File(infile.getParentFile(), sid.substring(2));
+ f = new File( infile.getParentFile(), sid.substring( 2 ) );
                 }
                 else {
                     // handle fully qualified name or in same directory
- f = new File(sid);
- if (!f.exists()) {
- if (infile == null)
+ f = new File( sid );
+ if ( !f.exists() ) {
+ if ( infile == null )
                             return null;
- if (!infile.isDirectory())
- f = new File(infile.getParentFile(), sid);
+ if ( !infile.isDirectory() )
+ f = new File( infile.getParentFile(), sid );
                         else
- f = new File(infile, sid);
+ f = new File( infile, sid );
                     }
                 }
- if (f.exists()) {
+ if ( f.exists() ) {
                     try {
- InputSource is = new InputSource(new FileReader(f));
- is.setPublicId(publicId);
- is.setSystemId(systemId);
+ InputSource is = new InputSource( new FileReader( f ) );
+ is.setPublicId( publicId );
+ is.setSystemId( systemId );
                         return is;
                     }
- catch (Exception e) {
+ catch ( Exception e ) {
                         StringBuffer sb = new StringBuffer();
- sb.append("<html>Error loading included resource: ").append(systemId).​append("<br>")​;
- sb.append("at line number: ").append(locator.ge​tLineNumber()).appen​d(", col number: ").append(locator.ge​tColumnNumber()).app​end("<p>");
- sb.append("The specific error is: ").append(e.getMessa​ge()).append("<p​>");
- sb.append("Do you want to load the rest of the file?");
- int rtn = JOptionPane.showConf​irmDialog(null, sb.toString(), "Error loading build file", JOptionPane.ERROR_MESSAGE);
- if (rtn == JOptionPane.NO_OPTION)
- throw new RuntimeException(e);
+ sb.append( "<html>Error loading included resource: " ).append( systemId ).append( "<br>" );
+ sb.append( "at line number: " ).append( locator.getLineNumber() ).append( ", col number: " ).append( locator.getColumnNumber() ).append( "<p>" );
+ sb.append( "The specific error is: " ).append( e.getMessage() ).append( "<p>" );
+ sb.append( "Do you want to load the rest of the file?" );
+ int rtn = JOptionPane.showConfirmDialog( null, sb.toString(), "Error loading build file", JOptionPane.ERROR_MESSAGE );
+ if ( rtn == JOptionPane.NO_OPTION )
+ throw new RuntimeException( e );
                         return null;
                     }
                 }
                 else {
                     try {
- InputSource is = new InputSource(new java.net.URL(systemI​d).openStream());
- is.setPublicId(publicId);
- is.setSystemId(systemId);
+ InputSource is = new InputSource( new java.net.URL( systemId ).openStream() );
+ is.setPublicId( publicId );
+ is.setSystemId( systemId );
                         return is;
                     }
- catch (Exception e) {
+ catch ( Exception e ) {
                         StringBuffer sb = new StringBuffer();
- sb.append("<html>Error loading included resource: ").append(systemId).​append("<br>")​;
- sb.append("at line number: ").append(locator.ge​tLineNumber()).appen​d(", col number: ").append(locator.ge​tColumnNumber()).app​end("<p>");
- sb.append("The specific error is: ").append(e.getMessa​ge()).append("<p​>");
- sb.append("Do you want to load the rest of the file?");
- int rtn = JOptionPane.showConf​irmDialog(null, sb.toString(), "Error loading build file", JOptionPane.ERROR_MESSAGE);
- if (rtn == JOptionPane.NO_OPTION)
- throw new RuntimeException(e);
+ sb.append( "<html>Error loading included resource: " ).append( systemId ).append( "<br>" );
+ sb.append( "at line number: " ).append( locator.getLineNumber() ).append( ", col number: " ).append( locator.getColumnNumber() ).append( "<p>" );
+ sb.append( "The specific error is: " ).append( e.getMessage() ).append( "<p>" );
+ sb.append( "Do you want to load the rest of the file?" );
+ int rtn = JOptionPane.showConfirmDialog( null, sb.toString(), "Error loading build file", JOptionPane.ERROR_MESSAGE );
+ if ( rtn == JOptionPane.NO_OPTION )
+ throw new RuntimeException( e );
                         return null;
                     }
                 }
@@ -450,16 +452,16 @@
      * @param qname the name of the node
      * @param node the node itself
      */
- private void setKind(String qname, SAXTreeNode node) {
- if (qname.equals("project")) {
- node.setProject(true);
- }
- else if (qname.equals("target"))
- node.setTarget(true);
- else if (taskList.contains(qname))
- node.setTask(true);
- else if (typeList.contains(qname))
- node.setType(true);
+ private void setKind( String qname, SAXTreeNode node ) {
+ if ( qname.equals( "project" ) ) {
+ node.setProject( true );
+ }
+ else if ( qname.equals( "target" ) )
+ node.setTarget( true );
+ else if ( taskList.contains( qname ) )
+ node.setTask( true );
+ else if ( typeList.contains( qname ) )
+ node.setType( true );
     }
 
     /**
@@ -468,20 +470,20 @@
      * @param child The feature to be added to the PropertyFile attribute
      * @param attr_name The feature to be added to the PropertyFile attribute
      */
- private void addPropertyFile(SAXTreeNode child, String attr_name) {
- if (propertyFiles == null)
+ private void addPropertyFile( SAXTreeNode child, String attr_name ) {
+ if ( propertyFiles == null )
             propertyFiles = new HashMap();
- String filename = child.getAttributeVa​lue(attr_name);
- File f = new File(filename);
- if (!f.exists()) {
- if (child.getFile() != null) {
- f = new File(child.getFile()​.getParentFile(), filename);
+ String filename = child.getAttributeValue( attr_name );
+ File f = new File( filename );
+ if ( !f.exists() ) {
+ if ( child.getFile() != null ) {
+ f = new File( child.getFile().getP​arentFile(), filename );
             }
         }
- if (f.exists())
- propertyFiles.put(f, new Long(f.lastModified()));
+ if ( f.exists() )
+ propertyFiles.put( f, new Long( f.lastModified() ) );
         else {
- propertyFiles.put(filename, new Long(0));
+ propertyFiles.put( filename, new Long( 0 ) );
             //_logger.warning("Warning:" + Constants.NL + "Property file " + filename + " not found, will attempt to resolve later.");
         }
     }
@@ -500,5 +502,4 @@
         return propertyFiles;
     }
 
-}
-
+}
\ No newline at end of file

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r163 - trunk/src/ise/antelope/common/SAXNodeHandler.java danson Dale Anson 2009-05-18 05:37:54 PDT
Messages per page: