org.apache.cocoon.components.language.programming.java
Class JstyleFormatter
java.lang.Object
|
+--org.apache.avalon.framework.logger.AbstractLoggable
|
+--org.apache.cocoon.components.language.programming.java.JstyleFormatter
- All Implemented Interfaces:
- CodeFormatter, org.apache.avalon.framework.logger.Loggable
- public class JstyleFormatter
- extends org.apache.avalon.framework.logger.AbstractLoggable
- implements CodeFormatter
This class implements CodeFormatter
based on
Tal Davidson's (davidsont@bigfoot.com) Jstyle Java
beautifier. This implementation is very improvised...
- Version:
- CVS $Id: JstyleFormatter.java,v 1.5 2002/02/22 07:00:09 cziegeler Exp $
- Author:
- Ricardo Rocha
Method Summary |
java.lang.String |
format(java.lang.String code,
java.lang.String encoding)
Format and beautify a String containing source code.
|
protected java.lang.String |
getString(java.io.ByteArrayOutputStream out,
java.lang.String encoding)
Convert a byte array stream to string according to a given encoding.
|
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable |
getLogger, setLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PREFERRED_LINE_LENGTH
protected static final int PREFERRED_LINE_LENGTH
- The default preferred line length. Should be parametrized!
LINE_LENGTH_DEVIATION
protected static final int LINE_LENGTH_DEVIATION
- The default line length deviation. Should be parametrized!
SPACE_INDENTATION
protected static final int SPACE_INDENTATION
- The default space indentation. Should be parametrized!
JstyleFormatter
public JstyleFormatter()
format
public java.lang.String format(java.lang.String code,
java.lang.String encoding)
- Format and beautify a
String
containing source code.
This class has 2 pases: one for beautifying and another one for
indentation. This should be performed in a single step!!!
- Specified by:
format
in interface CodeFormatter
- Parameters:
code
- The input source codeencoding
- The encoding used for constant strings embedded in the
source code- Returns:
- The formatted source code
getString
protected java.lang.String getString(java.io.ByteArrayOutputStream out,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
- Convert a byte array stream to string according to a given encoding.
The encoding can be
null
for the platform's default
encoding
- Parameters:
PARAM_NAME
- Param description- Returns:
- the value
- Throws:
EXCEPTION_NAME
- If an error occurs
Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.