cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: cocoon-2.1/tools/src/anttasks ManifestToolTask.java XConfToolTask.java
Date Mon, 08 Mar 2004 07:57:06 GMT
antonio     2004/03/07 23:57:06

  Modified:    tools/src/anttasks ManifestToolTask.java XConfToolTask.java
  Log:
  Adding Apache License 2.0 + formatting code
  
  Revision  Changes    Path
  1.2       +32 -28    cocoon-2.1/tools/src/anttasks/ManifestToolTask.java
  
  Index: ManifestToolTask.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/tools/src/anttasks/ManifestToolTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ManifestToolTask.java	9 Mar 2003 00:11:45 -0000	1.1
  +++ ManifestToolTask.java	8 Mar 2004 07:57:06 -0000	1.2
  @@ -1,16 +1,25 @@
  -/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        *
  - * ------------------------------------------------------------------------- *
  - * This software is published under the terms of the Apache Software License *
  - * version 1.1, a copy of which has been included  with this distribution in *
  - * the LICENSE file.                                                         *
  - *****************************************************************************/
  -
  -import java.io.*;
  -import java.util.*;
  -import org.apache.tools.ant.*;
  -import org.apache.tools.ant.taskdefs.*;
  -import org.apache.tools.ant.types.*;
  +/*
  + * Copyright 1999-2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +import java.io.File;
  +import java.io.FileWriter;
  +import java.io.IOException;
  +
  +import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.Task;
   
   /**
    * Creates Manifest file with the all the JARs and modification dates
  @@ -52,9 +61,8 @@
       /**
        * Scan recursive
        */
  -    private void process(final File directoryFile,
  -                         final String manifest)
  -    throws IOException, BuildException {
  +    private void process(final File directoryFile, final String manifest)
  +            throws IOException, BuildException {
   
           System.out.println("Writing: " + manifest);
           FileWriter w = new FileWriter(this.project.resolveFile(manifest));
  @@ -64,25 +72,21 @@
               w.write("Cocoon-Libs: ");
   
               final File[] files = directoryFile.listFiles();
  -            for(int i = 0; i < files.length; i++) {
  +            for (int i = 0; i < files.length; i++) {
                   if (files[i].getName().endsWith(".jar")) {
  -                    w.write(files[i].getName());
  -                    w.write(" ");
  +                    w.write(files[i].getName() + " ");
                   }
               }
               w.write("\n");
   
  -            for(int i = 0; i < files.length; i++) {
  +            for (int i = 0; i < files.length; i++) {
                   if (files[i].getName().endsWith(".jar")) {
  -                    w.write("Cocoon-Lib-");
  -                    String s = files[i].getName().replace('.', '_');
  -                    w.write(s);
  -                    w.write(": ");
  -                    w.write(String.valueOf(files[i].lastModified()));
  -                    w.write("\n");
  +                    w.write("Cocoon-Lib-" +
  +                            files[i].getName().replace('.', '_') +
  +                            ": " + String.valueOf(files[i].lastModified()) +
  +                            "\n");
                   }
               }
  -
           }
           w.close();
       }
  
  
  
  1.16      +32 -39    cocoon-2.1/tools/src/anttasks/XConfToolTask.java
  
  Index: XConfToolTask.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/tools/src/anttasks/XConfToolTask.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XConfToolTask.java	5 Mar 2004 13:21:22 -0000	1.15
  +++ XConfToolTask.java	8 Mar 2004 07:57:06 -0000	1.16
  @@ -69,7 +69,7 @@
       private static final String NL=System.getProperty("line.separator");
       private static final String FSEP=System.getProperty("file.separator");
       private File file;
  -    private File directory;
  +    //private File directory;
       private File srcdir;
       private boolean addComments;
       /** for resolving entities such as dtds */
  @@ -98,8 +98,7 @@
        *
        * @param xmlCatalog the XMLCatalog instance to use to look up DTDs
        */
  -    public void addConfiguredXMLCatalog(XMLCatalog xmlCatalog)
  -    {
  +    public void addConfiguredXMLCatalog(XMLCatalog xmlCatalog) {
         this.xmlCatalog.addConfiguredXMLCatalog(xmlCatalog);
       }
   
  @@ -114,8 +113,7 @@
       /**
        * Initialize internal instance of XMLCatalog
        */
  -    public void init() throws BuildException
  -    {
  +    public void init() throws BuildException {
         super.init();
         xmlCatalog.setProject(project);
       }
  @@ -124,12 +122,9 @@
        * Execute task.
        */
       public void execute() throws BuildException {
  -
  -        if (this.file==null) {
  -            throw new BuildException("file attribute is required",
  -                                     location);
  +        if (this.file == null) {
  +            throw new BuildException("file attribute is required", location);
           }
  -
           try {
               final DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
               builderFactory.setValidating(false);
  @@ -145,17 +140,16 @@
               log("Reading: " + this.file, Project.MSG_DEBUG);
               final Document document = builder.parse(this.file.toURL().toExternalForm());
   
  -            if (this.srcdir==null)
  +            if (this.srcdir == null) {
                   this.srcdir = project.resolveFile(".");
  +            }
   
               DirectoryScanner scanner = getDirectoryScanner(this.srcdir);
  -
               String[] list = scanner.getIncludedFiles();
  -
               boolean hasChanged = false;
               // process recursive
               File patchfile;
  -            for (int i = 0; i<list.length; i++) {
  +            for (int i = 0; i < list.length; i++) {
                   patchfile = new File(this.srcdir, list[i]);
                   try {
                       // Adds configuration snippet from the file to the configuration
  @@ -168,7 +162,7 @@
               }
   
               if (hasChanged) {
  -                log("Writing: "+this.file);
  +                log("Writing: " + this.file);
                   // Set the DOCTYPE output option on the transformer 
                   // if we have any DOCTYPE declaration in the input xml document
                   final DocumentType doctype = document.getDoctype();
  @@ -218,7 +212,7 @@
           String extension = file.lastIndexOf(".")>0?file.substring(file.lastIndexOf(".")+1):"";
           String basename = basename(file);
   
  -        if ( !elem.getTagName().equals(extension)) {
  +        if (!elem.getTagName().equals(extension)) {
               log("Skipping non xconf-tool file: "+file);
               return false;
           }
  @@ -233,40 +227,40 @@
   
           NodeList nodes = XPathAPI.selectNodeList(configuration, xpath);
   
  -        if (nodes.getLength()!=1) {
  +        if (nodes.getLength() !=1 ) {
               log("Error in: "+file);
  -            throw new IOException("XPath ("+xpath+
  +            throw new IOException("XPath (" + xpath +
                                     ") returned not one node, but "+
  -                                  nodes.getLength()+" nodes");
  +                                  nodes.getLength() + " nodes");
           }
           Node root = nodes.item(0);
   
           // Test that 'root' node satisfies 'component' insertion criteria
           String testPath = getAttribute(elem, "unless-path", replaceProperties);
  -        if (testPath == null || testPath.length()==0) {
  +        if (testPath == null || testPath.length() == 0) {
               // only look for old "unless" attr if unless-path is not present
               testPath = getAttribute(elem, "unless", replaceProperties);
           }
           // Is if-path needed?
           String ifProp = getAttribute(elem, "if-prop", replaceProperties);
           boolean ifValue = false;
  -        if (ifProp != null && !ifProp.equals(""))
  +        if (ifProp != null && !ifProp.equals("")) {
               Boolean.valueOf(project.getProperty(ifProp)).booleanValue();
  +        }
   
  -        if (ifProp != null && (ifProp.length()>0) && !ifValue ) {
  +        if (ifProp != null && ifProp.length() > 0 && !ifValue ) {
               log("Skipping: " + file, Project.MSG_DEBUG);
               return false;
  -        } else if ((testPath!=null) && (testPath.length()>0) &&
  -            (XPathAPI.selectNodeList(root, testPath).getLength()!=0)) {
  +        } else if (testPath != null && testPath.length() > 0 &&
  +            XPathAPI.selectNodeList(root, testPath).getLength() != 0) {
               log("Skipping: " + file, Project.MSG_DEBUG);
               return false;
           } else {
               // Test if component wants us to remove a list of nodes first
               xpath = getAttribute(elem, "remove", replaceProperties);
  -
               Node remove = null;
   
  -            if ((xpath!=null) && (xpath.length()>0)) {
  +            if (xpath != null && xpath.length() > 0) {
                   nodes = XPathAPI.selectNodeList(configuration, xpath);
   
                   for (int i = 0, length = nodes.getLength(); i<length; i++) {
  @@ -281,8 +275,8 @@
               String name = getAttribute(elem, "add-attribute", replaceProperties);
               String value = getAttribute(elem, "value", replaceProperties);
   
  -            if ((name!=null) && (name.length()>0)) {
  -                if (value==null) {
  +            if (name != null && name.length() > 0) {
  +                if (value == null) {
                       throw new IOException("No attribute value specified for 'add-attribute'
"+
                                             xpath);
                   }
  @@ -295,22 +289,21 @@
               xpath = getAttribute(elem, "insert-before", replaceProperties);
               Node before = null;
   
  -            if ((xpath!=null) && (xpath.length()>0)) {
  +            if (xpath != null && xpath.length() > 0) {
                   nodes = XPathAPI.selectNodeList(root, xpath);
  -                if (nodes.getLength()==0) {
  +                if (nodes.getLength() == 0) {
                       log("Error in: "+file);
                       throw new IOException("XPath ("+xpath+") returned zero nodes");
                   }
                   before = nodes.item(0);
               } else {
                   xpath = getAttribute(elem, "insert-after", replaceProperties);
  -                if ((xpath!=null) && (xpath.length()>0)) {
  +                if (xpath != null && xpath.length() > 0) {
                       nodes = XPathAPI.selectNodeList(root, xpath);
  -                    if (nodes.getLength()==0) {
  +                    if (nodes.getLength() == 0) {
                           log("Error in: "+file);
                           throw new IOException("XPath ("+xpath+") zero nodes.");
                       }
  -                    
                       before = nodes.item(nodes.getLength()-1).getNextSibling();
                   }
               }
  @@ -356,10 +349,9 @@
       }
   
       private void replaceProperties(Node n) throws DOMException {
  -
           NamedNodeMap attrs = n.getAttributes();
  -        if (attrs!=null) {
  -            for (int i = 0; i< attrs.getLength(); i++) {
  +        if (attrs != null) {
  +            for (int i = 0; i < attrs.getLength(); i++) {
                   Node attr = attrs.item(i);
                   attr.setNodeValue(getProject().replaceProperties(attr.getNodeValue()));
    
               } 
  @@ -392,8 +384,9 @@
           int start = file.lastIndexOf(FSEP)+1; // last '/'
           int end = file.lastIndexOf(".");  // last '.'
   
  -        if (end == 0) end = file.length();
  -
  +        if (end == 0) {
  +            end = file.length();
  +        }
           return file.substring(start, end);
       }
   }
  
  
  

Mime
View raw message