User: pathoss
Date: 02/05/12 04:58:04
Modified: core/src/xdoclet/util Tag: MODULE_REFACTORING_BRANCH
DocletUtil.java FileManager.java Translator.java
TypeConversionUtil.java XmlValidator.java
Added: core/src/xdoclet/util Tag: MODULE_REFACTORING_BRANCH
LogUtil.java
Removed: core/src/xdoclet/util Tag: MODULE_REFACTORING_BRANCH
Log.java
Log:
1. use jakarta commons logging (and LogUtil)
2. coding conventions (voted, applied pretty.settings)
3. minor refactorings
Revision Changes Path
No revision
No revision
1.17.2.2 +25 -23 xdoclet/core/src/xdoclet/util/DocletUtil.java
Index: DocletUtil.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/DocletUtil.java,v
retrieving revision 1.17.2.1
retrieving revision 1.17.2.2
diff -u -w -r1.17.2.1 -r1.17.2.2
--- DocletUtil.java 28 Apr 2002 22:40:28 -0000 1.17.2.1
+++ DocletUtil.java 12 May 2002 11:58:04 -0000 1.17.2.2
@@ -10,9 +10,10 @@
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @author <a href="[EMAIL PROTECTED]">Aslak Helles�y</a>
* @created July 14, 2001
- * @version $Revision: 1.17.2.1 $
+ * @version $Revision: 1.17.2.2 $
*/
-public final class DocletUtil {
+public final class DocletUtil
+{
/**
* Return an array of String from a String containing delimited values. For
@@ -22,7 +23,8 @@
* @param delimiter the delimiter ("," or ";" for example)
* @return an array of String delimited value
*/
- public static String[] tokenizeDelimitedToArray(String delimited, String
delimiter) {
+ public static String[] tokenizeDelimitedToArray(String delimited, String
delimiter)
+ {
StringTokenizer st = new StringTokenizer(delimited, delimiter);
String[] ret = new String[st.countTokens()];
int i = 0;
1.10.2.3 +3 -15 xdoclet/core/src/xdoclet/util/FileManager.java
Index: FileManager.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/FileManager.java,v
retrieving revision 1.10.2.2
retrieving revision 1.10.2.3
diff -u -w -r1.10.2.2 -r1.10.2.3
--- FileManager.java 9 May 2002 16:42:50 -0000 1.10.2.2
+++ FileManager.java 12 May 2002 11:58:04 -0000 1.10.2.3
@@ -22,15 +22,12 @@
*
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Aug 5, 2001
- * @version $Revision: 1.10.2.2 $
+ * @version $Revision: 1.10.2.3 $
* @todo Deal with Translator.getString()'s exception better (throw it so
* the build stops?) in getFileContent(String)
*/
public final class FileManager
{
- /**
- * @todo-javadoc Describe the field
- */
private final static Map urlCache = new HashMap();
/**
@@ -38,7 +35,6 @@
*
* @param url Describe what the parameter does
* @return The URLContent value
- * @todo-javadoc Write javadocs for method parameter
*/
public static synchronized String getURLContent(URL url)
{
@@ -87,10 +83,6 @@
* @param url Describe what the parameter does
* @param destination Describe what the parameter does
* @exception IOException Describe the exception
- * @todo-javadoc Write javadocs for method
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for exception
*/
public static synchronized void writeURLContent(URL url, File destination)
throws IOException
{
@@ -107,10 +99,6 @@
* @param is Describe what the parameter does
* @param os Describe what the parameter does
* @exception IOException Describe the exception
- * @todo-javadoc Write javadocs for method
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for exception
*/
private static void pump(InputStream is, OutputStream os) throws IOException
{
1.5.2.2 +132 -182 xdoclet/core/src/xdoclet/util/Translator.java
Index: Translator.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/Translator.java,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -w -r1.5.2.1 -r1.5.2.2
--- Translator.java 28 Apr 2002 22:40:28 -0000 1.5.2.1
+++ Translator.java 12 May 2002 11:58:04 -0000 1.5.2.2
@@ -4,28 +4,21 @@
*/
package xdoclet.util;
-import org.apache.log4j.Category;
-
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import org.apache.commons.logging.Log;
+
/**
* Utility class for doing i18n translations.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Andrew Stevens</a>
* @created Jan 18, 2002
- * @version $Revision: 1.5.2.1 $
+ * @version $Revision: 1.5.2.2 $
*/
public class Translator
{
- /**
- * @todo-javadoc Describe the field
- */
private final static java.lang.String DEFAULT_BUNDLE = "xdoclet.Messages";
-
- /**
- * @todo-javadoc Describe the field
- */
private static java.util.Map bundles = new java.util.HashMap();
/**
@@ -40,8 +33,6 @@
*
* @param resourceKey Describe what the parameter does
* @return The String value
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for exception
*/
public static java.lang.String getString( String resourceKey )
{
@@ -54,9 +45,6 @@
* @param resourceKey Describe what the parameter does
* @param arguments Describe what the parameter does
* @return The String value
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for exception
*/
public static java.lang.String getString( String resourceKey, String[]
arguments )
{
@@ -69,9 +57,6 @@
* @param bundleKey Describe what the parameter does
* @param resourceKey Describe what the parameter does
* @return The String value
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for exception
*/
public static java.lang.String getString( String bundleKey, String resourceKey
)
{
@@ -85,61 +70,45 @@
* @param resourceKey Describe what the parameter does
* @param arguments Describe what the parameter does
* @return The String value
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for exception
*/
public static java.lang.String getString( String bundleKey, String
resourceKey, String[] arguments )
{
- Category cat = Log.getCategory( Translator.class, "getString" );
+ Log log = LogUtil.getLog(Translator.class, "getString");
- if( cat.isDebugEnabled() )
- {
- cat.debug( "bundleKey=" + bundleKey );
- cat.debug( "resourceKey=" + resourceKey );
- if( arguments == null )
- {
- cat.debug( "no arguments" );
+ if (log.isDebugEnabled()) {
+ log.debug("bundleKey=" + bundleKey);
+ log.debug("resourceKey=" + resourceKey);
+ if (arguments == null) {
+ log.debug("no arguments");
}
- else
- {
- cat.debug( "#arguments=" + arguments.length );
- for( int i = 0; i < arguments.length; i++ )
- {
- cat.debug( "arg #" + i + "=" + arguments[i] );
+ else {
+ log.debug("#arguments=" + arguments.length);
+ for (int i = 0; i < arguments.length; i++) {
+ log.debug("arg #" + i + '=' + arguments[i]);
}
}
}
- if( bundleKey == null )
- {
+ if (bundleKey == null) {
bundleKey = DEFAULT_BUNDLE;
}
- try
- {
+
+ try {
ResourceBundle bundle = getBundle( bundleKey );
String resource = bundle.getString( resourceKey );
- if( cat.isDebugEnabled() )
- {
- cat.debug( "resource=" + resource );
- }
+ log.debug("resource=" + resource);
String msg = java.text.MessageFormat.format( resource,
arguments );
- if( cat.isDebugEnabled() )
- {
- cat.debug( "return message: " + msg );
- }
+ log.debug("return message: " + msg);
return msg;
}
- catch( MissingResourceException e )
- {
+ catch (MissingResourceException e) {
// No i18n for this one, or we risk an infinite recursion...
// throw new XDocletException( "Can't locate resource '" +
resourceKey + "' for bundle '" + bundleKey + "'." );
- cat.error( "XDoclet BUG: Can't locate resource '" +
resourceKey + "' for bundle '" + bundleKey + "'." );
+ log.error("XDoclet BUG: Can't locate resource '" + resourceKey + "' for
bundle '" + bundleKey + "'.");
return resourceKey;
}
}
@@ -150,51 +119,32 @@
* @param bundleKey Describe what the parameter does
* @return The Bundle value
* @exception MissingResourceException Describe the exception
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for exception
*/
private static ResourceBundle getBundle( java.lang.String bundleKey )
throws MissingResourceException
{
- Category cat = Log.getCategory( Translator.class, "getBundle" );
+ Log log = LogUtil.getLog(Translator.class, "getBundle");
- if( cat.isDebugEnabled() )
- {
- cat.debug( "bundleKey=" + bundleKey );
- }
+ log.debug("bundleKey=" + bundleKey);
- if( bundles.containsKey( bundleKey ) )
- {
- if( cat.isDebugEnabled() )
- {
- cat.debug( "bundle found in cache" );
- }
+ if (bundles.containsKey(bundleKey)) {
+ log.debug("bundle found in cache");
return ( ResourceBundle ) bundles.get( bundleKey );
}
- else
- {
- try
- {
- if( cat.isDebugEnabled() )
- {
- cat.debug( "bundle not cached, loading" );
- }
+ else {
+ try {
+ log.debug("bundle not cached, loading");
ResourceBundle bundle = ResourceBundle.getBundle(
bundleKey );
bundles.put( bundleKey, bundle );
return bundle;
}
- catch( MissingResourceException e )
- {
+ catch (MissingResourceException e) {
// only caught in order to have the chance to log it
- if( cat.isDebugEnabled() )
- {
- cat.debug( "bundle not found" );
- }
+ log.debug("bundle not found");
throw e;
}
}
}
-
}
1.4.2.1 +32 -30 xdoclet/core/src/xdoclet/util/TypeConversionUtil.java
Index: TypeConversionUtil.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/TypeConversionUtil.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -w -r1.4 -r1.4.2.1
--- TypeConversionUtil.java 4 Apr 2002 01:03:08 -0000 1.4
+++ TypeConversionUtil.java 12 May 2002 11:58:04 -0000 1.4.2.1
@@ -7,19 +7,21 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.4.2.1 $
*/
-public final class TypeConversionUtil {
+public final class TypeConversionUtil
+{
/**
- * A utility method for converting a string to a boolean. "yes", "no", "true"
- * and "false" are valid values for a boolean string. If not one of then then
- * the value of default_value parameter is returned.
+ * A utility method for converting a string to a boolean. "yes", "no",
+ * "true" and "false" are valid values for a boolean string. If not one of
+ * then then the value of default_value parameter is returned.
*
* @param str Description of Parameter
* @param default_value Description of Parameter
* @return Description of the Returned Value
*/
- public static boolean stringToBoolean(String str, boolean default_value) {
+ public static boolean stringToBoolean(String str, boolean default_value)
+ {
if (str == null) {
return default_value;
}
1.12.2.3 +22 -43 xdoclet/core/src/xdoclet/util/XmlValidator.java
Index: XmlValidator.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/XmlValidator.java,v
retrieving revision 1.12.2.2
retrieving revision 1.12.2.3
diff -u -w -r1.12.2.2 -r1.12.2.3
--- XmlValidator.java 9 May 2002 16:42:50 -0000 1.12.2.2
+++ XmlValidator.java 12 May 2002 11:58:04 -0000 1.12.2.3
@@ -13,8 +13,8 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
+import org.apache.commons.logging.Log;
-import org.apache.log4j.Category;
import org.apache.tools.ant.AntClassLoader;
import org.xml.sax.InputSource;
@@ -35,7 +35,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Aslak Helles�y</a>
* @created September 18, 2001
- * @version $Revision: 1.12.2.2 $
+ * @version $Revision: 1.12.2.3 $
* @todo Deal with Translator.getString()'s exception better in
* resolveEntity(String, String)
*/
@@ -46,14 +46,9 @@
* The crimson implementation is shipped with ant.
*/
public static String DEFAULT_XML_READER_CLASSNAME =
"org.apache.crimson.parser.XMLReaderImpl";
- /**
- * @todo-javadoc Describe the field
- */
+
private static XmlValidator instance = new XmlValidator(null);
- /**
- * @todo-javadoc Describe the field
- */
protected ClassLoader classLoader;
/**
@@ -61,22 +56,14 @@
*/
protected XMLReader xmlReader = null;
- /**
- * @todo-javadoc Describe the field
- */
protected String readerClassName = DEFAULT_XML_READER_CLASSNAME;
- /**
- * @todo-javadoc Describe the field
- */
private final HashMap _dtds = new HashMap();
/**
* Describe what the XmlValidator constructor does
*
* @param classLoader Describe what the parameter does
- * @todo-javadoc Write javadocs for constructor
- * @todo-javadoc Write javadocs for method parameter
*/
public XmlValidator(ClassLoader classLoader)
{
@@ -114,10 +101,10 @@
*/
public void registerDTD(String publicId, URL dtdURL)
{
- Category cat = Log.getCategory(XmlValidator.class, "registerDTD");
+ Log log = LogUtil.getLog(XmlValidator.class, "registerDTD");
- if (cat.isDebugEnabled()) {
- cat.debug("DTD '" + dtdURL + "' registered for public Id '" + publicId
+ "'.");
+ if (log.isDebugEnabled()) {
+ log.debug("DTD '" + dtdURL + "' registered for public Id '" + publicId
+ "'.");
}
_dtds.put(publicId, dtdURL);
@@ -137,11 +124,11 @@
*/
public InputSource resolveEntity(String publicId, String systemId)
{
- Category cat = Log.getCategory(XmlValidator.class, "resolveEntity");
+ Log log = LogUtil.getLog(XmlValidator.class, "resolveEntity");
- if (cat.isDebugEnabled()) {
- cat.debug("publicId=" + publicId);
- cat.debug("systemId=" + systemId);
+ if (log.isDebugEnabled()) {
+ log.debug("publicId=" + publicId);
+ log.debug("systemId=" + systemId);
}
URL dtdURL = (URL) _dtds.get(publicId);
@@ -149,18 +136,15 @@
if (dtdURL != null) {
String dtd = FileManager.getURLContent(dtdURL);
- if (cat.isDebugEnabled()) {
- cat.debug("dtdURL != null, dtdURL=" + dtdURL);
- cat.debug("dtd.length()=" + dtd.length());
+ if (log.isDebugEnabled()) {
+ log.debug("dtdURL != null, dtdURL=" + dtdURL);
+ log.debug("dtd.length()=" + dtd.length());
}
return new InputSource(new StringReader(dtd));
}
else {
- if (cat.isDebugEnabled()) {
- cat.debug("dtdURL == null");
- }
-
+ log.debug("dtdURL == null");
System.out.println(Translator.getString("couldnt_load_local_dtd", new
String[]{publicId}));
return null;
}
@@ -220,17 +204,14 @@
*
* @param xml_file Describe what the parameter does
* @exception XDocletException Describe the exception
- * @todo-javadoc Write javadocs for method
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for exception
*/
private void doValidate(File xml_file) throws XDocletException
{
- Category cat = Log.getCategory(XmlValidator.class, "doValidate");
+ Log log = LogUtil.getLog(XmlValidator.class, "doValidate");
try {
- if (cat.isDebugEnabled()) {
- cat.debug("Validating " + xml_file.getName() + "... ");
+ if (log.isDebugEnabled()) {
+ log.debug("Validating " + xml_file.getName() + "... ");
}
//errorHandler.init( afile );
@@ -267,12 +248,10 @@
* Describe what the method does
*
* @exception XDocletException Describe the exception
- * @todo-javadoc Write javadocs for method
- * @todo-javadoc Write javadocs for exception
*/
private void initValidatorHack() throws XDocletException
{
- Category cat = Log.getCategory(XmlValidator.class, "initValidator");
+ Log log = LogUtil.getLog(XmlValidator.class, "initValidator");
try {
// load the parser class
@@ -291,8 +270,8 @@
if (XMLReader.class.isAssignableFrom(readerClass)) {
xmlReader = (XMLReader) readerClass.newInstance();
- if (cat.isDebugEnabled()) {
- cat.debug("Using SAX2 reader " + readerClassName);
+ if (log.isDebugEnabled()) {
+ log.debug("Using SAX2 reader " + readerClassName);
}
}
else {
@@ -302,8 +281,8 @@
xmlReader = new ParserAdapter(parser);
- if (cat.isDebugEnabled()) {
- cat.debug("Using SAX1 parser " + readerClassName);
+ if (log.isDebugEnabled()) {
+ log.debug("Using SAX1 parser " + readerClassName);
}
}
else {
No revision
No revision
1.1.2.1 +29 -0 xdoclet/core/src/xdoclet/util/Attic/LogUtil.java
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel