vgritsenko    2002/08/16 20:49:51

  Modified:    src/java/org/apache/cocoon/generation
                        LinkStatusGenerator.java
               src/java/org/apache/cocoon/environment/commandline
                        LinkSamplingEnvironment.java
  Log:
  reformat
  
  Revision  Changes    Path
  1.7       +42 -42    
xml-cocoon2/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java
  
  Index: LinkStatusGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LinkStatusGenerator.java  17 Aug 2002 03:25:39 -0000      1.6
  +++ LinkStatusGenerator.java  17 Aug 2002 03:49:51 -0000      1.7
  @@ -86,24 +86,23 @@
    * @author Nicola Ken Barozzi ([EMAIL PROTECTED])
    * @author Bernhard Huber ([EMAIL PROTECTED])
    */
  -
   public class LinkStatusGenerator extends ComposerGenerator implements Recyclable, 
Configurable {
       /** The URI of the namespace of this generator. */
       protected static final String URI =
  -    "http://apache.org/cocoon/linkstatus/2.0";;
  +            "http://apache.org/cocoon/linkstatus/2.0";;
   
       /** The namespace prefix for this namespace. */
       protected static final String PREFIX = "linkstatus";
   
       /* Node and attribute names */
  -    protected static final String TOP_NODE_NAME         = "linkstatus";
  -    protected static final String LINK_NODE_NAME         = "link";
  +    protected static final String TOP_NODE_NAME = "linkstatus";
  +    protected static final String LINK_NODE_NAME = "link";
   
  -    protected static final String HREF_ATTR_NAME    = "href";
  -    protected static final String REFERRER_ATTR_NAME    = "referrer";
  -    protected static final String CONTENT_ATTR_NAME    = "content";
  -    protected static final String STATUS_ATTR_NAME    = "status";
  -    protected static final String MESSAGE_ATTR_NAME    = "message";
  +    protected static final String HREF_ATTR_NAME = "href";
  +    protected static final String REFERRER_ATTR_NAME = "referrer";
  +    protected static final String CONTENT_ATTR_NAME = "content";
  +    protected static final String STATUS_ATTR_NAME = "status";
  +    protected static final String MESSAGE_ATTR_NAME = "message";
   
       protected AttributesImpl attributes = new AttributesImpl();
   
  @@ -220,7 +219,7 @@
           private URL url;
           private String referrer;
   
  -        public Link( URL url, String referrer ) {
  +        public Link(URL url, String referrer) {
               this.url = url;
               this.referrer = referrer;
           }
  @@ -233,8 +232,8 @@
               return referrer;
           }
   
  -        public boolean equals( Link l ) {
  -            return url.equals( l.getURL());
  +        public boolean equals(Link l) {
  +            return url.equals(l.getURL());
           }
       }
   
  @@ -263,7 +262,7 @@
        * @since
        */
       public void configure(Configuration configuration)
  -    throws ConfigurationException {
  +            throws ConfigurationException {
   
           Configuration[] children;
           children = configuration.getChildren(INCLUDE_CONFIG);
  @@ -279,7 +278,7 @@
                       }
                   } catch (RESyntaxException rese) {
                       getLogger().error("Cannot create including regular-expression 
for " +
  -                    pattern, rese);
  +                            pattern, rese);
                   }
               }
           }
  @@ -297,7 +296,7 @@
                       }
                   } catch (RESyntaxException rese) {
                       getLogger().error("Cannot create excluding regular-expression 
for " +
  -                    pattern, rese);
  +                            pattern, rese);
                   }
               }
           } else {
  @@ -340,7 +339,7 @@
       }
   
       public void setup(SourceResolver resolver, Map objectModel, String src, 
Parameters par)
  -    throws ProcessingException, SAXException, IOException {
  +            throws ProcessingException, SAXException, IOException {
   
           super.setup(resolver, objectModel, src, par);
   
  @@ -361,14 +360,14 @@
        *      if the requsted URI wasn't found
        */
       public void generate()
  -    throws SAXException, ProcessingException {
  +            throws SAXException, ProcessingException {
           try {
   
               crawled = new HashSet();
               linksToProcess = new HashSet();
   
               URL root = new URL(source);
  -            linksToProcess.add(new Link( root, ""));
  +            linksToProcess.add(new Link(root, ""));
   
   
               if (getLogger().isDebugEnabled()) {
  @@ -376,10 +375,10 @@
               }
   
               this.contentHandler.startDocument();
  -            this.contentHandler.startPrefixMapping(PREFIX,URI);
  +            this.contentHandler.startPrefixMapping(PREFIX, URI);
   
               attributes.clear();
  -            super.contentHandler.startElement(URI, TOP_NODE_NAME, 
URI+':'+TOP_NODE_NAME, attributes);
  +            super.contentHandler.startElement(URI, TOP_NODE_NAME, URI + ':' + 
TOP_NODE_NAME, attributes);
   
               while (linksToProcess.size() > 0) {
                   Iterator i = linksToProcess.iterator();
  @@ -406,7 +405,7 @@
                   }
               }
   
  -            super.contentHandler.endElement(URI, TOP_NODE_NAME, 
URI+':'+TOP_NODE_NAME);
  +            super.contentHandler.endElement(URI, TOP_NODE_NAME, URI + ':' + 
TOP_NODE_NAME);
               this.contentHandler.endPrefixMapping(PREFIX);
               this.contentHandler.endDocument();
           } catch (IOException ioe) {
  @@ -445,7 +444,7 @@
                   excludeCrawlingURL.add(new RE(pattern));
               } catch (RESyntaxException rese) {
                   getLogger().error("Cannot create excluding regular-expression for " 
+
  -                pattern, rese);
  +                        pattern, rese);
               }
           }
       }
  @@ -466,12 +465,12 @@
           List url_links = null;
           BufferedReader br = null;
           try {
  -            URL url_link = new URL( url_link_string );
  +            URL url_link = new URL(url_link_string);
               URLConnection conn = url_link.openConnection();
               String content_type = conn.getContentType();
   
               if (content_type == null) {
  -                getLogger().warn( "No content type available for " + 
String.valueOf( url_link_string ) );
  +                getLogger().warn("No content type available for " + 
String.valueOf(url_link_string));
                   // caller checks if null
                   return url_links;
               }
  @@ -504,7 +503,7 @@
                           add_url &= !crawled.contains(new_url.toString());
                       }
   
  -                    Link new_link = new Link( new_url, referrer );
  +                    Link new_link = new Link(new_url, referrer);
                       if (add_url) {
                           add_url &= !linksToProcess.contains(new_link);
                       }
  @@ -531,7 +530,8 @@
                   try {
                       br.close();
                       br = null;
  -                } catch (IOException ignored) {}
  +                } catch (IOException ignored) {
  +                }
               }
           }
           return url_links;
  @@ -563,33 +563,33 @@
   
           attributes.clear();
           attributes.addAttribute("", HREF_ATTR_NAME,
  -        HREF_ATTR_NAME, "CDATA", url.toString());
  +                HREF_ATTR_NAME, "CDATA", url.toString());
           attributes.addAttribute("", REFERRER_ATTR_NAME,
  -        REFERRER_ATTR_NAME, "CDATA", referrer);
  +                REFERRER_ATTR_NAME, "CDATA", referrer);
   
           // Output url, referrer, content-type, status, message for traversable url's
           HttpURLConnection h = null;
           try {
   
               URLConnection links_url_connection = url.openConnection();
  -            h = (HttpURLConnection)links_url_connection;
  +            h = (HttpURLConnection) links_url_connection;
               String content_type = links_url_connection.getContentType();
   
               attributes.addAttribute("", CONTENT_ATTR_NAME,
  -            CONTENT_ATTR_NAME, "CDATA",
  -            content_type);
  +                    CONTENT_ATTR_NAME, "CDATA",
  +                    content_type);
   
               attributes.addAttribute("", MESSAGE_ATTR_NAME,
  -            MESSAGE_ATTR_NAME, "CDATA",
  -            h.getResponseMessage());
  +                    MESSAGE_ATTR_NAME, "CDATA",
  +                    h.getResponseMessage());
   
               attributes.addAttribute("", STATUS_ATTR_NAME,
  -            STATUS_ATTR_NAME, "CDATA",
  -            String.valueOf(h.getResponseCode()));
  +                    STATUS_ATTR_NAME, "CDATA",
  +                    String.valueOf(h.getResponseCode()));
           } catch (IOException ioe) {
               attributes.addAttribute("", MESSAGE_ATTR_NAME,
  -            MESSAGE_ATTR_NAME, "CDATA",
  -            ioe.getMessage());
  +                    MESSAGE_ATTR_NAME, "CDATA",
  +                    ioe.getMessage());
           } finally {
               if (h != null) {
                   h.disconnect();
  @@ -598,15 +598,15 @@
   
           // don't try to get links of a url which is excluded from crawling
           // try to get links of a url which is included for crawling
  -        if (!isExcludedURL(url.toString()) && isIncludedURL( url.toString() )) {
  +        if (!isExcludedURL(url.toString()) && isIncludedURL(url.toString())) {
               // add prefix and query to get data from the linkserializer.
               result = url.toExternalForm()
  -            + ((url.toExternalForm().indexOf("?") == -1) ? "?" : "&")
  -            + linkViewQuery;
  +                    + ((url.toExternalForm().indexOf("?") == -1) ? "?" : "&")
  +                    + linkViewQuery;
           }
   
  -        super.contentHandler.startElement(URI, LINK_NODE_NAME, 
URI+':'+LINK_NODE_NAME, attributes);
  -        super.contentHandler.endElement(URI, LINK_NODE_NAME, 
URI+':'+LINK_NODE_NAME);
  +        super.contentHandler.startElement(URI, LINK_NODE_NAME, URI + ':' + 
LINK_NODE_NAME, attributes);
  +        super.contentHandler.endElement(URI, LINK_NODE_NAME, URI + ':' + 
LINK_NODE_NAME);
   
           return result;
       }
  
  
  
  1.10      +39 -38    
xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java
  
  Index: LinkSamplingEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LinkSamplingEnvironment.java      4 Aug 2002 18:31:25 -0000       1.9
  +++ LinkSamplingEnvironment.java      17 Aug 2002 03:49:51 -0000      1.10
  @@ -1,36 +1,36 @@
   /*
  - 
  +
    ============================================================================
                      The Apache Software License, Version 1.1
    ============================================================================
  - 
  +
    Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  - 
  +
    Redistribution and use in source and binary forms, with or without modifica-
    tion, are permitted provided that the following conditions are met:
  - 
  +
    1. Redistributions of  source code must  retain the above copyright  notice,
       this list of conditions and the following disclaimer.
  - 
  +
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
  - 
  +
    3. The end-user documentation included with the redistribution, if any, must
       include  the following  acknowledgment:  "This product includes  software
       developed  by the  Apache Software Foundation  (http://www.apache.org/)."
       Alternately, this  acknowledgment may  appear in the software itself,  if
       and wherever such third-party acknowledgments normally appear.
  - 
  +
    4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
       used to  endorse or promote  products derived from  this software without
       prior written permission. For written permission, please contact
       [EMAIL PROTECTED]
  - 
  +
    5. Products  derived from this software may not  be called "Apache", nor may
       "Apache" appear  in their name,  without prior written permission  of the
       Apache Software Foundation.
  - 
  +
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  @@ -41,12 +41,12 @@
    ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
    (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  +
    This software  consists of voluntary contributions made  by many individuals
    on  behalf of the Apache Software  Foundation and was  originally created by
    Stefano Mazzocchi  <[EMAIL PROTECTED]>. For more  information on the Apache
    Software Foundation, please see <http://www.apache.org/>.
  - 
  +
    */
   package org.apache.cocoon.environment.commandline;
   
  @@ -69,50 +69,50 @@
    */
   
   public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment {
  -    
  +
       private boolean skip = false;
  -    
  -    public LinkSamplingEnvironment( String uri,
  -    File contextFile,
  -    Map attributes,
  -    Map parameters,
  -    Logger log )
  -    throws MalformedURLException, IOException {
  -        super( uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), 
log );
  +
  +    public LinkSamplingEnvironment(String uri,
  +                                   File contextFile,
  +                                   Map attributes,
  +                                   Map parameters,
  +                                   Logger log)
  +            throws MalformedURLException, IOException {
  +        super(uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), 
log);
           if (getLogger().isDebugEnabled()) {
  -            this.getLogger().debug( "LinkSamplingEnvironment: uri = " + uri );
  +            this.getLogger().debug("LinkSamplingEnvironment: uri = " + uri);
           }
  -        this.objectModel.put( ObjectModelHelper.REQUEST_OBJECT, new 
CommandLineRequest( this, null, uri, null, attributes, parameters ) );
  -        this.objectModel.put( ObjectModelHelper.RESPONSE_OBJECT, new 
CommandLineResponse() );
  +        this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, new 
CommandLineRequest(this, null, uri, null, attributes, parameters));
  +        this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, new 
CommandLineResponse());
       }
  -    
  +
       /**
        * Set the ContentType
        */
  -    public void setContentType( String contentType ) {
  -        if ( ! Constants.LINK_CONTENT_TYPE.equals( contentType ) ) {
  +    public void setContentType(String contentType) {
  +        if (!Constants.LINK_CONTENT_TYPE.equals(contentType)) {
               this.skip = true;
           }
       }
  -    
  +
       /**
        * Indicates if other links are present.
        */
       public Collection getLinks() throws IOException {
           ArrayList list = new ArrayList();
  -        if ( !skip ) {
  +        if (!skip) {
               BufferedReader buffer = null;
               try {
                   buffer = new BufferedReader(
  -                new InputStreamReader(
  -                new ByteArrayInputStream(
  -                ( ( ByteArrayOutputStream ) super.stream ).toByteArray())));
  -                
  -                while ( true ) {
  +                        new InputStreamReader(
  +                                new ByteArrayInputStream(
  +                                        ((ByteArrayOutputStream) 
super.stream).toByteArray())));
  +
  +                while (true) {
                       String line = buffer.readLine();
  -                    if ( line == null )
  +                    if (line == null)
                           break;
  -                    list.add( line );
  +                    list.add(line);
                   }
               } finally {
                   // explictly close the input
  @@ -120,10 +120,11 @@
                       try {
                           buffer.close();
                           buffer = null;
  -                    } catch (IOException ignored) {}
  +                    } catch (IOException ignored) {
  +                    }
                   }
               }
           }
  -        return list;        
  +        return list;
       }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to