cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject cvs commit: cocoon-2.0/src/java/org/apache/cocoon/components/language/markup/xsp XSPUtil.java
Date Wed, 11 Jun 2003 23:26:42 GMT
joerg       2003/06/11 16:26:42

  Modified:    src/java/org/apache/cocoon/components/language/markup/xsp
                        XSPUtil.java
  Log:
  code formatting
  
  Revision  Changes    Path
  1.3       +59 -61    cocoon-2.0/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java
  
  Index: XSPUtil.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.0/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSPUtil.java	31 May 2003 00:24:52 -0000	1.2
  +++ XSPUtil.java	11 Jun 2003 23:26:42 -0000	1.3
  @@ -170,11 +170,9 @@
           return result;
       }
   
  -    public static void include(InputSource is, ContentHandler parentContentHandler, Parser
parser)
  -        throws SAXException, IOException {
  -            parser.setConsumer(
  -                new IncludeXMLConsumer(parentContentHandler));
  -            parser.parse(is);
  +    public static void include(InputSource is, ContentHandler parentContentHandler, Parser
parser) throws SAXException, IOException {
  +        parser.setConsumer(new IncludeXMLConsumer(parentContentHandler));
  +        parser.parse(is);
       }
   
       public static String encodeMarkup(String string) {
  @@ -200,15 +198,15 @@
       }
   
       public static String formEncode(String text) throws Exception {
  -    return URLEncoder.encode (text);
  +        return URLEncoder.encode(text);
       }
   
       // Shameless, ain't it?
       public static String formDecode(String s) throws Exception {
  -    return URLDecoder.decode (s);
  +        return URLDecoder.decode(s);
       }
   
  -  /* Logicsheet Utility Methods */
  +    /* Logicsheet Utility Methods */
   
       // Inclusion
       public static String getURLContents(String url, URLFactory urlFactory) throws IOException
{
  @@ -220,23 +218,19 @@
       }
   
       public static String getFileContents(String filename) throws IOException {
  -        return getContents(
  -            new BufferedReader(new FileReader(filename)));
  +        return getContents(new BufferedReader(new FileReader(filename)));
       }
   
       public static String getFileContents(String filename, String encoding) throws IOException
{
  -        return getContents(
  -            new BufferedInputStream(new FileInputStream(filename)), encoding);
  +        return getContents(new BufferedInputStream(new FileInputStream(filename)), encoding);
       }
   
       public static String getContents(InputStream in, String encoding) throws IOException
{
  -        return getContents(
  -            new BufferedReader(new InputStreamReader(in, encoding)));
  +        return getContents(new BufferedReader(new InputStreamReader(in, encoding)));
       }
   
       public static String getContents(InputStream in) throws IOException {
  -        return getContents(
  -            new BufferedReader(new InputStreamReader(in)));
  +        return getContents(new BufferedReader(new InputStreamReader(in)));
       }
   
       public static String getContents(Reader reader) throws IOException {
  @@ -255,8 +249,7 @@
               pattern = "yyyy/MM/dd hh:mm:ss aa";
           }
           try {
  -            return (
  -                new SimpleDateFormat(pattern)).format(date);
  +            return (new SimpleDateFormat(pattern)).format(date);
           } catch (Exception e) {
               return date.toString();
           }
  @@ -270,20 +263,18 @@
       }
   
       public static int getSessionCount(Session session) {
  -        synchronized(session) {
  +        synchronized (session) {
               Integer integer = (Integer)session.getAttribute("util.counter");
               if (integer == null) {
                   integer = new Integer(0);
               }
               int cnt = integer.intValue() + 1;
  -            session.setAttribute("util.counter",
  -                new Integer(cnt));
  +            session.setAttribute("util.counter", new Integer(cnt));
               return cnt;
           }
       }
   
  -    public static Object getContextAttribute(Map objectModel, String name)
  -    {
  +    public static Object getContextAttribute(Map objectModel, String name) {
           Context context = ObjectModelHelper.getContext(objectModel);
           return context.getAttribute(name);
       }
  @@ -301,80 +292,87 @@
                   byte[] buffer = new byte[(new Long(length)).intValue()];
                   stream.read(buffer);
                   stream.close();
  -                if (buffer != null) result.append(new String(buffer));
  +                if (buffer != null) {
  +                    result.append(new String(buffer));
  +                }
               } else {
                   int readBytes = 0;
                   do {
  -                    byte[] buffer = new byte[4*1024];
  +                    byte[] buffer = new byte[4 * 1024];
                       readBytes = stream.read(buffer);
  -                    if (readBytes == -1) break;
  -                    if (readBytes > 0) result.append(new String(buffer,0,readBytes));
  +                    if (readBytes == -1) {
  +                        break;
  +                    }
  +                    if (readBytes > 0) {
  +                        result.append(new String(buffer, 0, readBytes));
  +                    }
                   } while (true);
                   stream.close();
               }
           } catch (Exception e) {
               throw new CascadingRuntimeException("Failed to get " + uri + " as string",
e);
           } finally {
  -            if ( stream != null )
  +            if (stream != null) {
                   try {
                       stream.close();
                   } catch (Exception ase) {
                       throw new CascadingRuntimeException("Failed to close stream", ase);
                   }
  -            if ( resource != null )
  +            }
  +            if (resource != null) {
                   resource.recycle();
  +            }
           }
           return result.toString();
       }
   
   
  -    public static void includeSource(String uri, String base, SourceResolver resolver,
ContentHandler contentHandler) 
  -        throws RuntimeException {
  -        
  -        base = (base == null? "" : base);
  +    public static void includeSource(String uri, String base, SourceResolver resolver,
ContentHandler contentHandler)
  +            throws RuntimeException {
  +        base = (base == null ? "" : base);
           Source source = null;
           try {
  -            source = resolver.resolve(base+uri);
  +            source = resolver.resolve(base + uri);
               source.toSAX(new org.apache.cocoon.xml.IncludeXMLConsumer(contentHandler));
  -          } catch (Exception e) {
  -              throw new CascadingRuntimeException("Error including source "+base+" "+uri,
e);
  -          } finally {
  -              if (source != null)
  -                 source.recycle();
  -          }
  -    }
  -    
  -    public static void includeString(String string, ComponentManager manager, ContentHandler
contentHandler) 
  -        throws RuntimeException {
  -
  -        XSPUtil.includeInputSource(new InputSource( new StringReader( String.valueOf(string))),
manager, contentHandler);
  -    }
  -        
  -    public static void includeFile(String name, ComponentManager manager, ContentHandler
contentHandler, Map objectModel) 
  -        throws RuntimeException {
  +        } catch (Exception e) {
  +            throw new CascadingRuntimeException("Error including source " + base + " "
+ uri, e);
  +        } finally {
  +            if (source != null) {
  +                source.recycle();
  +            }
  +        }
  +    }
  +
  +    public static void includeString(String string, ComponentManager manager, ContentHandler
contentHandler)
  +            throws RuntimeException {
  +        XSPUtil.includeInputSource(new InputSource(new StringReader(String.valueOf(string))),
manager,
  +                                   contentHandler);
  +    }
   
  +    public static void includeFile(String name, ComponentManager manager, ContentHandler
contentHandler, Map objectModel)
  +            throws RuntimeException {
           try {
  -            XSPUtil.includeInputSource(new InputSource(new FileReader(XSPUtil.relativeFilename(name,objectModel))),

  +            XSPUtil.includeInputSource(new InputSource(new FileReader(XSPUtil.relativeFilename(name,
objectModel))),
                                          manager, contentHandler);
           } catch (IOException e) {
  -            throw new CascadingRuntimeException("Could not include file "+name, e);
  +            throw new CascadingRuntimeException("Could not include file " + name, e);
           }
  -    }   
  +    }
   
  -    public static void includeInputSource(InputSource source, ComponentManager manager,
ContentHandler contentHandler) 
  -        throws RuntimeException {
  -        
  +    public static void includeInputSource(InputSource source, ComponentManager manager,
ContentHandler contentHandler)
  +            throws RuntimeException {
           Parser newParser = null;
  -        
           try {
  -            newParser = (Parser) manager.lookup(Parser.ROLE);
  +            newParser = (Parser)manager.lookup(Parser.ROLE);
               XSPUtil.include(source, contentHandler, newParser);
           } catch (Exception e) {
               throw new CascadingRuntimeException("Could not include page", e);
           } finally {
  -            if (newParser != null) manager.release(newParser);
  +            if (newParser != null) {
  +                manager.release(newParser);
  +            }
           }
       }
  -        
  +
   
   }
  
  
  

Mime
View raw message