vgritsenko 2003/08/07 11:03:22
Modified: java/src/org/apache/xindice/client/xmldb DatabaseImpl.java java/src/org/apache/xindice/client/xmldb/embed CollectionImpl.java DatabaseImpl.java java/src/org/apache/xindice/client/xmldb/managed ManagedDatabaseImpl.java java/src/org/apache/xindice/client/xmldb/xmlrpc DatabaseImpl.java java/src/org/apache/xindice/core Collection.java CollectionManager.java Database.java MetaSystemCollection.java SystemCollection.java java/src/org/apache/xindice/core/filer BTree.java BTreeFiler.java FSFiler.java HashFiler.java java/src/org/apache/xindice/core/indexer IndexManager.java MemValueIndexer.java NameIndexer.java ValueIndexer.java java/src/org/apache/xindice/core/meta MetaData.java java/src/org/apache/xindice/core/meta/inline InlineHeaderBuilder.java InlineMetaService.java ResourceTypeReader.java java/src/org/apache/xindice/core/query QueryEngine.java XPathQueryResolver.java java/src/org/apache/xindice/core/request URIMapper.java java/src/org/apache/xindice/core/xupdate XUpdateQueryResolver.java java/src/org/apache/xindice/server ManagedServer.java XindiceServlet.java java/src/org/apache/xindice/tools XMLTools.java java/src/org/apache/xindice/tools/command Command.java ListCollections.java XPathQuery.java XUpdate.java java/src/org/apache/xindice/util Configuration.java SymbolSerializer.java java/src/org/apache/xindice/xml TextWriter.java java/src/org/apache/xindice/xml/dom CharacterDataImpl.java ContainerNodeImpl.java DocumentImpl.java ElementImpl.java EntityReferenceImpl.java ProcessingInstructionImpl.java java/src/org/apache/xindice/xml/jaxp DocumentBuilderImpl.java java/src/org/apache/xindice/xml/sax SAXEventGenerator.java Log: Make logger final everywhere. Use getLogger(Class) method. Revision Changes Path 1.18 +2 -2 xml-xindice/java/src/org/apache/xindice/client/xmldb/DatabaseImpl.java Index: DatabaseImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/DatabaseImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- DatabaseImpl.java 4 Aug 2003 03:01:57 -0000 1.17 +++ DatabaseImpl.java 7 Aug 2003 18:03:20 -0000 1.18 @@ -80,7 +80,7 @@ */ public class DatabaseImpl extends CommonConfigurable implements Database { - private static Log log = LogFactory.getLog("org.apache.xindice.client.xmldb"); + private static final Log log = LogFactory.getLog(DatabaseImpl.class); protected Database driver; 1.18 +7 -5 xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java Index: CollectionImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- CollectionImpl.java 6 Aug 2003 05:43:55 -0000 1.17 +++ CollectionImpl.java 7 Aug 2003 18:03:20 -0000 1.18 @@ -58,9 +58,6 @@ * * $Id$ */ -import java.util.Enumeration; -import java.util.Hashtable; - import org.apache.xindice.client.xmldb.ResourceSetImpl; import org.apache.xindice.client.xmldb.XindiceCollection; import org.apache.xindice.client.xmldb.resources.BinaryResourceImpl; @@ -75,6 +72,7 @@ import org.apache.xindice.xml.NamespaceMap; import org.apache.xindice.xml.dom.DBNode; import org.apache.xindice.xml.dom.DocumentImpl; + import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -85,6 +83,9 @@ import org.xmldb.api.modules.BinaryResource; import org.xmldb.api.modules.XMLResource; +import java.util.Enumeration; +import java.util.Hashtable; + /** * Implementation of XML:DB's <code>Collection</code> interface using * direct access to interact with database server @@ -93,6 +94,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Kimbro Staken</a> */ public class CollectionImpl extends XindiceCollection { + Database db = null; Collection col = null; @@ -146,7 +148,7 @@ return new XMLResourceImpl(id, id, this, ((DocumentImpl) doc).getSymbols(), ((DocumentImpl) doc).getDataBytes()); } else if (entry instanceof byte[]) { - return new BinaryResourceImpl(id, (byte[]) entry); + return new BinaryResourceImpl(id, entry); } else { throw new XMLDBException( ErrorCodes.UNKNOWN_RESOURCE_TYPE, 1.15 +2 -2 xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/DatabaseImpl.java Index: DatabaseImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/DatabaseImpl.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- DatabaseImpl.java 1 Aug 2003 19:35:51 -0000 1.14 +++ DatabaseImpl.java 7 Aug 2003 18:03:20 -0000 1.15 @@ -86,7 +86,7 @@ */ public class DatabaseImpl extends CommonConfigurable implements org.xmldb.api.base.Database { - private static Log log = LogFactory.getLog("org.apache.xindice.client.embed"); + private static final Log log = LogFactory.getLog(DatabaseImpl.class); /** prefix used to denote XML:DB URI's that should use this driver */ public static final String DRIVER_NAME = "xindice-embed"; 1.3 +4 -3 xml-xindice/java/src/org/apache/xindice/client/xmldb/managed/ManagedDatabaseImpl.java Index: ManagedDatabaseImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/managed/ManagedDatabaseImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ManagedDatabaseImpl.java 1 Aug 2003 19:35:51 -0000 1.2 +++ ManagedDatabaseImpl.java 7 Aug 2003 18:03:21 -0000 1.3 @@ -88,6 +88,8 @@ */ public class ManagedDatabaseImpl extends CommonConfigurable implements org.xmldb.api.base.Database { + private static final Log log = LogFactory.getLog(ManagedDatabaseImpl.class); + /** * Prefix used to denote XML:DB URI's that should use this driver */ @@ -100,7 +102,6 @@ */ public static final String CONFORMANCE_LEVEL = "0"; - private final Log log = LogFactory.getLog(getClass()); protected Database db; 1.13 +16 -7 xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java Index: DatabaseImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- DatabaseImpl.java 4 Aug 2003 22:20:51 -0000 1.12 +++ DatabaseImpl.java 7 Aug 2003 18:03:21 -0000 1.13 @@ -79,19 +79,28 @@ */ public class DatabaseImpl extends CommonConfigurable implements Database { - /* prefix used to denote XML:DB URI's that should use this driver */ + private static final Log log = LogFactory.getLog(DatabaseImpl.class); + + /** + * Prefix used to denote XML:DB URI's that should use this driver + */ static String DRIVER_NAME = "xindice"; - /* XML:DB conformance level of this driver */ + /** + * XML:DB conformance level of this driver + */ private String CONFORMANCE_LEVEL = "0"; - /* Property name for the xml-rpc service location. */ + /** + * Property name for the xml-rpc service location. + */ private static final String PROP_SERVICE_LOCATION = "service-location"; - /* Property name for the SAX parser xml-rpc will use. */ + /** + * Property name for the SAX parser xml-rpc will use. + */ private static final String PROP_XMLRPC_DRIVER = "xmlrpc-driver"; - - private static Log log = LogFactory.getLog("org.apache.xindice.client.xmldb.xmlrpc"); + /** * Create a new DatabaseImpl object. 1.26 +33 -33 xml-xindice/java/src/org/apache/xindice/core/Collection.java Index: Collection.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/Collection.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- Collection.java 5 Aug 2003 00:02:45 -0000 1.25 +++ Collection.java 7 Aug 2003 18:03:21 -0000 1.26 @@ -106,10 +106,40 @@ * Collection represents a collection of Documents maintains links to * the Filer storage implementation, and the Indexes associated with * the Collection. - **/ - + */ public class Collection extends CollectionManager implements Named, DBObject, Configurable { + private static final Log log = LogFactory.getLog(Collection.class); + + private static final String CACHE = "cache"; + private static final String CLASS = "class"; + private static final String CLASSNAME = "xindice-class"; + private static final String COMPRESSED = "compressed"; + private static final DocumentSet EMPTY_DOCUMENTSET = new EmptyDocumentSet(); + private static final NodeSet EMPTY_NODESET = new EmptyNodeSet(); + private static final String[] EMPTY_STRING_ARRAY = {}; + private static final String FILER = "filer"; + private static int host_id; + private static final String INDEXES = "indexes"; + private static final String INLINE_METADATA = "inline-metadata"; + private static final String NAME = "name"; + private static final String SYMBOLS = "symbols"; + + static { + try { + InetAddress a = InetAddress.getLocalHost(); + byte[] b = a.getAddress(); + host_id = 0; + host_id += b[0]; + host_id += (b[1] << 8); + host_id += (b[2] << 16); + host_id += (b[3] << 24); + host_id = Math.abs(host_id); + } catch (Exception e) { + log.warn(e); + } + } + /** * ColContainer */ @@ -201,36 +231,6 @@ } } - private static final String CACHE = "cache"; - private static final String CLASS = "class"; - private static final String CLASSNAME = "xindice-class"; - private static final String COMPRESSED = "compressed"; - private static final DocumentSet EMPTY_DOCUMENTSET = new EmptyDocumentSet(); - private static final NodeSet EMPTY_NODESET = new EmptyNodeSet(); - private static final String[] EMPTY_STRING_ARRAY = {}; - private static final String FILER = "filer"; - private static int host_id; - private static final String INDEXES = "indexes"; - private static final String INLINE_METADATA = "inline-metadata"; - private static Log log = LogFactory.getLog("org.apache.xindice.core"); - private static final String NAME = "name"; - private static final String SYMBOLS = "symbols"; - - static { - try { - InetAddress a = InetAddress.getLocalHost(); - byte[] b = a.getAddress(); - host_id = 0; - host_id += b[0]; - host_id += (b[1] << 8); - host_id += (b[2] << 16); - host_id += (b[3] << 24); - host_id = Math.abs(host_id); - } catch (Exception e) { - - log.warn(e); - } - } private String canonicalName; // Object ID Stuff 1.14 +7 -4 xml-xindice/java/src/org/apache/xindice/core/CollectionManager.java Index: CollectionManager.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/CollectionManager.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- CollectionManager.java 1 Aug 2003 19:40:17 -0000 1.13 +++ CollectionManager.java 7 Aug 2003 18:03:21 -0000 1.14 @@ -74,15 +74,18 @@ /** * CollectionManager is the base class for both Database and Collection. */ - public class CollectionManager implements Configurable, Disposable { + + private static final Log log = LogFactory.getLog(CollectionManager.class); + private static final String COLLECTION = "collection"; private static final String COLLECTIONS = "collections"; private static final String[] EmptyStrings = new String[0]; - private static Log log = LogFactory.getLog("org.apache.xindice.core"); private static final String NAME = "name"; - private Map collections = new HashMap(); // Collection + + private final Map collections = new HashMap(); // Collection private Configuration config = null; + protected CollectionManager() { } 1.24 +3 -2 xml-xindice/java/src/org/apache/xindice/core/Database.java Index: Database.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/Database.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- Database.java 1 Aug 2003 19:40:17 -0000 1.23 +++ Database.java 7 Aug 2003 18:03:21 -0000 1.24 @@ -83,6 +83,8 @@ */ public final class Database extends Collection implements Named { + private static final Log log = LogFactory.getLog(Database.class); + public static final String DBROOT = "dbroot"; public static final String NAME = "name"; private static final String QUERYENGINE = "queryengine"; @@ -92,7 +94,6 @@ public static final String DBROOT_DEFAULT = "./db/"; - private static Log log = LogFactory.getLog("org.apache.xindice.core"); private static final Map databases = new HashMap(); // String to Database /** 1.5 +7 -4 xml-xindice/java/src/org/apache/xindice/core/MetaSystemCollection.java Index: MetaSystemCollection.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/MetaSystemCollection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MetaSystemCollection.java 1 Aug 2003 19:40:17 -0000 1.4 +++ MetaSystemCollection.java 7 Aug 2003 18:03:21 -0000 1.5 @@ -75,13 +75,16 @@ * for Meta data management. */ public final class MetaSystemCollection extends Collection { + + private static final Log log = LogFactory.getLog(MetaSystemCollection.class); + public static final String METACOL = "meta"; public static final String METAS = "Metas"; public static final String COLLECTION_META_DATA = "_META_DATA_"; private String dbCanonicalName; private String metaCanonicalName; - private static Log log = LogFactory.getLog("org.apache.xindice.core"); + public MetaSystemCollection(Database db) { super(db); @@ -90,8 +93,8 @@ public void init() throws DBException { // Bootstrap the System Collection - String MetaCol = - "<collection name=\"" + METACOL + "\">" + String MetaCol + = "<collection name=\"" + METACOL + "\">" // Meta System Collections + " <collections>" // Meta Collections 1.17 +3 -3 xml-xindice/java/src/org/apache/xindice/core/SystemCollection.java Index: SystemCollection.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/SystemCollection.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- SystemCollection.java 1 Aug 2003 19:40:17 -0000 1.16 +++ SystemCollection.java 7 Aug 2003 18:03:21 -0000 1.17 @@ -73,9 +73,10 @@ * standard Collection operations, this class will provide facilities * for Schema and SymbolTable management among other things. */ - public final class SystemCollection extends Collection { + private static final Log log = LogFactory.getLog(SystemCollection.class); + public static final String SYSCOL = "system"; public static final String SYMBOLS = "SysSymbols"; public static final String OBJECTS = "SysObjects"; @@ -83,7 +84,6 @@ public static final String USERS = "SysUsers"; public static final String GROUPS = "SysGroups"; public static final String ACCESS = "SysAccess"; - private static Log log = LogFactory.getLog("org.apache.xindice.core"); /** * @param db 1.13 +4 -3 xml-xindice/java/src/org/apache/xindice/core/filer/BTree.java Index: BTree.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/BTree.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- BTree.java 1 Aug 2003 19:40:17 -0000 1.12 +++ BTree.java 7 Aug 2003 18:03:21 -0000 1.13 @@ -103,11 +103,12 @@ */ public class BTree extends Paged { + + private static final Log log = LogFactory.getLog(BTree.class); + protected static final byte LEAF = 1; protected static final byte BRANCH = 2; protected static final byte STREAM = 3; - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); private Map cache = new WeakHashMap(); 1.11 +5 -3 xml-xindice/java/src/org/apache/xindice/core/filer/BTreeFiler.java Index: BTreeFiler.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/BTreeFiler.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- BTreeFiler.java 1 Aug 2003 19:40:17 -0000 1.10 +++ BTreeFiler.java 7 Aug 2003 18:03:21 -0000 1.11 @@ -85,15 +85,17 @@ */ public final class BTreeFiler extends BTree implements Configurable, Filer { + + private static final Log log = LogFactory.getLog(BTreeFiler.class); + protected static final byte RECORD = 20; private static final String PAGESIZE = "pagesize"; private static final String MAXKEYSIZE = "maxkeysize"; - private static Log log = LogFactory.getLog("org.apache.xindice.core"); - private Configuration config; private BTreeFilerHeader fileHeader; + public BTreeFiler() { super(); 1.10 +5 -5 xml-xindice/java/src/org/apache/xindice/core/filer/FSFiler.java Index: FSFiler.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/FSFiler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- FSFiler.java 1 Aug 2003 19:40:17 -0000 1.9 +++ FSFiler.java 7 Aug 2003 18:03:21 -0000 1.10 @@ -84,14 +84,13 @@ /** * FSFiler allows you to use existing file systems withing Xindice. */ - public final class FSFiler extends SimpleConfigurable implements Filer { + + private static final Log log = LogFactory.getLog(FSFiler.class); + private static final String LOCATION = "location"; private static final String EXT = "ext"; private static final String READONLY = "readonly"; - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); - private FileCache cache = new FileCache(); private LockManager locks = new LockManager(16); @@ -101,6 +100,7 @@ private File dir; private boolean opened = false; private boolean readOnly = false; + public FSFiler() { } 1.13 +6 -6 xml-xindice/java/src/org/apache/xindice/core/filer/HashFiler.java Index: HashFiler.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/HashFiler.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- HashFiler.java 1 Aug 2003 19:40:17 -0000 1.12 +++ HashFiler.java 7 Aug 2003 18:03:21 -0000 1.13 @@ -89,20 +89,20 @@ * * @deprecated This class has been temporarily (maybe indefinitely) * deprecated by BTreeFiler. - **/ - + */ public final class HashFiler extends Paged implements Configurable, Filer { + + private static final Log log = LogFactory.getLog(HashFiler.class); + protected static final byte RECORD = 1; private static final String PAGECOUNT = "pagecount"; private static final String PAGESIZE = "pagesize"; private static final String MAXKEYSIZE = "maxkeysize"; - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); - private Configuration config; private HashFileHeader fileHeader; //private BTree btree; + public HashFiler() { super(); 1.14 +4 -5 xml-xindice/java/src/org/apache/xindice/core/indexer/IndexManager.java Index: IndexManager.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/indexer/IndexManager.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- IndexManager.java 1 Aug 2003 19:40:17 -0000 1.13 +++ IndexManager.java 7 Aug 2003 18:03:21 -0000 1.14 @@ -95,8 +95,10 @@ * IndexManager is a class that manages Indexes. Good description, eh? * I should win a Pulitzer Prize for that one. */ - public final class IndexManager extends SimpleConfigurable { + + private static final Log log = LogFactory.getLog(IndexManager.class); + private static final String[] EmptyStrings = new String[0]; private static final IndexerInfo[] EmptyIndexerInfo = new IndexerInfo[0]; @@ -111,9 +113,6 @@ private static final int ACTION_CREATE = 0; private static final int ACTION_UPDATE = 1; private static final int ACTION_DELETE = 2; - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); - private static final Timer indexTimer = new Timer(true); private Map patternMap = new HashMap(); // IndexPattern to IndexerInfo 1.3 +28 -30 xml-xindice/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java Index: MemValueIndexer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MemValueIndexer.java 1 Aug 2003 19:40:18 -0000 1.2 +++ MemValueIndexer.java 7 Aug 2003 18:03:21 -0000 1.3 @@ -81,6 +81,13 @@ * @version 3/18/2003 */ public class MemValueIndexer implements Indexer { + + /** + * log used by this indexer + */ + private static final Log log = LogFactory.getLog(MemValueIndexer.class); + + /** * Sets the parent Collection of this indexer. * @@ -126,12 +133,12 @@ /** * Removes the specified value reference from the index. * - * @param value The value to remove - * @param key The Object ID - * @param pos The offset into the stream the Element occurs at - * @param len The length of the substream for the Element - * @param elemID The Element ID of the value - * @param attrID The Attribute ID of the value (if any, else -1) + * @param theValue The value to remove + * @param theKey The Object ID + * @param thePosition The offset into the stream the Element occurs at + * @param theLength The length of the substream for the Element + * @param theElementID The Element ID of the value + * @param theAttributeID The Attribute ID of the value (if any, else -1) */ public synchronized void remove(String theValue, Key theKey, int thePosition, int theLength, short theElementID, short theAttributeID) throws DBException { Object aValue; @@ -167,11 +174,11 @@ * Adds a value reference to the index. * * @param theValue The value to add - * @param key The Object ID - * @param pos The offset into the stream the Element occurs at - * @param len The length of the substream for the Element - * @param elemID The Element ID of the value - * @param attrID The Attribute ID of the value (if any, else -1) + * @param theKey The Object ID + * @param thePosition The offset into the stream the Element occurs at + * @param theLength The length of the substream for the Element + * @param theElementID The Element ID of the value + * @param theAttributeID The Attribute ID of the value (if any, else -1) */ public synchronized void add(String theValue, Key theKey, int thePosition, int theLength, short theElementID, short theAttributeID) throws DBException { Object aValue; @@ -239,9 +246,7 @@ Object aLowEndpoint = aMatchValueArray[0]; Object aHighEndpoint = aMatchValueArray[aMatchValueArray.length - 1]; - Map aSubmap; Iterator aValueIterator; - int aLocatorCount = 0; int anOperator = theQuery.getOperator(); // perform the requested matching type @@ -358,7 +363,7 @@ // for starts-with aLowEndpoint = aQueryValueList[0]; if (itsValueType == TRIMMED) { - aLowEndpoint = (String) QueryEngine.normalizeString((String) aLowEndpoint); + aLowEndpoint = QueryEngine.normalizeString((String) aLowEndpoint); } else { if (itsValueType != STRING) { aLowEndpoint = ((String) aLowEndpoint).trim(); @@ -402,7 +407,7 @@ // to force String comparisons (as required for starts-with) aLowEndpoint = aQueryValueList[0]; if (itsValueType == TRIMMED) { - aLowEndpoint = (String) QueryEngine.normalizeString((String) aLowEndpoint); + aLowEndpoint = QueryEngine.normalizeString((String) aLowEndpoint); } else { if (itsValueType != STRING) { aLowEndpoint = ((String) aLowEndpoint).trim(); @@ -786,8 +791,8 @@ } } } catch (Exception anException) { - if (itsLog.isDebugEnabled()) { - itsLog.debug("Exception while setting configuration", anException); + if (log.isDebugEnabled()) { + log.debug("Exception while setting configuration", anException); } } } @@ -949,8 +954,8 @@ //break; } } catch (Exception anException) { - if (itsLog.isDebugEnabled()) { - itsLog.debug("Exception while converting value \"" + theValue + "\" from String to " + itsValueTypeName, anException); + if (log.isDebugEnabled()) { + log.debug("Exception while converting value \"" + theValue + "\" from String to " + itsValueTypeName, anException); } } return new String(); @@ -1059,7 +1064,6 @@ * stored in the TreeSet objects contained as values * in the specified map. If theMap is null, 0 is returned. * - * @param theArray array to add matches to * @param theMap map containing sets of ValueLocator objects to add as IndexMatches * @return the count of ValueLocator objects */ @@ -1130,11 +1134,6 @@ } /** - * log used by this indexer - */ - private static Log itsLog = LogFactory.getLog("org.apache.xindice.core.indexer"); - - /** * the indexed Collection */ private org.apache.xindice.core.Collection itsCollection; @@ -1187,8 +1186,8 @@ private static final String NAME = "name"; private static final String PATTERN = "pattern"; private static final String TYPE = "type"; - private static final String PAGESIZE = "pagesize"; - private static final String MAXKEYSIZE = "maxkeysize"; + // private static final String PAGESIZE = "pagesize"; + // private static final String MAXKEYSIZE = "maxkeysize"; private static final String STRING_VAL = "string"; private static final String TRIMMED_VAL = "trimmed"; @@ -1220,10 +1219,9 @@ * to String is an empty String. */ private static class EmptyValue extends Object implements Comparable { + /** * Creates a new object. - * - * @return a new Object */ EmptyValue() { } @@ -1355,7 +1353,7 @@ * @param theKey Key of the value (only the data member is used) * @param thePosition the value's position in the document stream * @param thePosition length of the value in the document stream - * @aram theElementID the ID of the Element containing the value + * @param theElementID the ID of the Element containing the value * @param theAttributeID the ID of the Attribute containing the value * * NOTE: I do not know if there are use cases where theKey.length != theLength 1.10 +4 -3 xml-xindice/java/src/org/apache/xindice/core/indexer/NameIndexer.java Index: NameIndexer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/indexer/NameIndexer.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- NameIndexer.java 1 Aug 2003 19:40:18 -0000 1.9 +++ NameIndexer.java 7 Aug 2003 18:03:21 -0000 1.10 @@ -83,14 +83,15 @@ */ public final class NameIndexer extends BTree implements Indexer { + + private static final Log log = LogFactory.getLog(NameIndexer.class); + private static final IndexMatch[] EmptyMatches = new IndexMatch[0]; private static final String NAME = "name"; private static final String PATTERN = "pattern"; private static final String PAGESIZE = "pagesize"; private static final String MAXKEYSIZE = "maxkeysize"; - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); private Configuration config; private Collection collection; 1.9 +4 -3 xml-xindice/java/src/org/apache/xindice/core/indexer/ValueIndexer.java Index: ValueIndexer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/indexer/ValueIndexer.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ValueIndexer.java 1 Aug 2003 19:40:18 -0000 1.8 +++ ValueIndexer.java 7 Aug 2003 18:03:21 -0000 1.9 @@ -85,6 +85,9 @@ */ public final class ValueIndexer extends BTree implements Indexer { + + private static final Log log = LogFactory.getLog(ValueIndexer.class); + private static final IndexMatch[] EmptyMatches = new IndexMatch[0]; private static final Value EmptyValue = new Value(new byte[0]); @@ -116,8 +119,6 @@ private static final String BYTE_VAL = "byte"; private static final String CHAR_VAL = "char"; private static final String BOOLEAN_VAL = "boolean"; - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); private Configuration config; private Collection collection; 1.4 +8 -6 xml-xindice/java/src/org/apache/xindice/core/meta/MetaData.java Index: MetaData.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/meta/MetaData.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MetaData.java 1 Aug 2003 19:40:18 -0000 1.3 +++ MetaData.java 7 Aug 2003 18:03:21 -0000 1.4 @@ -97,6 +97,9 @@ * @author Dave Viner <[EMAIL PROTECTED]> */ public class MetaData implements XMLSerializable { + + private static Log log = LogFactory.getLog(MetaData.class); + public final static short UNKNOWN = 0; public final static short COLLECTION = 1; public final static short DOCUMENT = 2; @@ -127,8 +130,6 @@ private transient long modified = 0; private transient String owner = null; - private static Log log = LogFactory.getLog("org.apache.xindice.core"); - private short type = UNKNOWN; private String link = null; private Hashtable attrs = null; @@ -372,7 +373,7 @@ /** * Copies from another meta data - * @param from the meta to copy from + * @param meta the meta to copy from */ public void copyFrom(final MetaData meta) { this.created = meta.getCreatedTime(); @@ -627,9 +628,10 @@ } this.custom.appendChild(custdoc); } else { -// ignore - if (log.isDebugEnabled()) + // ignore + if (log.isDebugEnabled()) { log.debug("ignoring unknown xml element " + elementName); + } } } } 1.3 +2 -2 xml-xindice/java/src/org/apache/xindice/core/meta/inline/InlineHeaderBuilder.java Index: InlineHeaderBuilder.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/meta/inline/InlineHeaderBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- InlineHeaderBuilder.java 1 Aug 2003 19:40:18 -0000 1.2 +++ InlineHeaderBuilder.java 7 Aug 2003 18:03:21 -0000 1.3 @@ -85,7 +85,7 @@ public class InlineHeaderBuilder { - private static Log log = LogFactory.getLog("org.apache.xindice.core.meta.inline"); + private static final Log log = LogFactory.getLog(InlineHeaderBuilder.class); /** * There's no reason to ever create an instance of this class. 1.4 +3 -3 xml-xindice/java/src/org/apache/xindice/core/meta/inline/InlineMetaService.java Index: InlineMetaService.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/meta/inline/InlineMetaService.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InlineMetaService.java 1 Aug 2003 19:40:18 -0000 1.3 +++ InlineMetaService.java 7 Aug 2003 18:03:21 -0000 1.4 @@ -72,6 +72,8 @@ */ public class InlineMetaService { + private static Log log = LogFactory.getLog(InlineMetaService.class); + /** * The known readers. All readers for header versions up to * and including the current version must be present in this array. @@ -89,8 +91,6 @@ * prior to a store, it is working with this class. */ public static final Class currentMapClass = ResourceTypeReader.ResourceTypeMap.class; - - private static Log log = LogFactory.getLog("org.apache.xindice.core.meta.inline"); /** * Get an <code>InlineMetaMap</code> instance corresponding to the 1.3 +7 -7 xml-xindice/java/src/org/apache/xindice/core/meta/inline/ResourceTypeReader.java Index: ResourceTypeReader.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/meta/inline/ResourceTypeReader.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ResourceTypeReader.java 1 Aug 2003 19:40:18 -0000 1.2 +++ ResourceTypeReader.java 7 Aug 2003 18:03:21 -0000 1.3 @@ -68,11 +68,11 @@ */ public class ResourceTypeReader implements InlineMetaReader { + private static Log log = LogFactory.getLog(ResourceTypeReader.class); + public static final Integer XML = new Integer(1); public static final Integer BINARY = new Integer(2); - private static Log log = LogFactory.getLog("org.apache.xindice.core.meta.inline"); - /** * @see org.apache.xindice.core.meta.inline.InlineMetaReader#getVersion() */ @@ -84,8 +84,9 @@ * @see org.apache.xindice.core.meta.inline.InlineMetaReader#read(byte[], int, int) */ public InlineMetaMap read(byte[] data, int offset, int length) throws InlineMetaException { - - log.debug("ResourceTypeReader.read: data length=" + data.length + " offset=" + offset + " length=" + length); + if (log.isDebugEnabled()) { + log.debug("ResourceTypeReader.read: data length=" + data.length + " offset=" + offset + " length=" + length); + } if (length != 1) { throw new InlineMetaException(FaultCodes.COL_DOCUMENT_MALFORMED, "Expecting header length of 1"); @@ -146,7 +147,7 @@ } /** - * @see org.apache.xindice.core.meta.inline.InlineMetaMap#put(String) + * @see org.apache.xindice.core.meta.inline.InlineMetaMap#put(String, Object) */ public void put(String key, Object value) throws InlineMetaException { if ("type".equals(key)) { @@ -160,5 +161,4 @@ } } } - } 1.6 +4 -3 xml-xindice/java/src/org/apache/xindice/core/query/QueryEngine.java Index: QueryEngine.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/query/QueryEngine.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- QueryEngine.java 1 Aug 2003 19:40:19 -0000 1.5 +++ QueryEngine.java 7 Aug 2003 18:03:21 -0000 1.6 @@ -88,13 +88,14 @@ */ public class QueryEngine extends SimpleConfigurable { + + private static final Log log = LogFactory.getLog(QueryEngine.class); + private static final String[] EmptyStrings = new String[0]; private static final Key[] EmptyKeys = new Key[0]; private static final String RESOLVER = "resolver"; private static final String CLASS = "class"; - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); private Database db; private Map resolvers = new HashMap(); 1.16 +4 -3 xml-xindice/java/src/org/apache/xindice/core/query/XPathQueryResolver.java Index: XPathQueryResolver.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/query/XPathQueryResolver.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- XPathQueryResolver.java 6 Aug 2003 05:48:14 -0000 1.15 +++ XPathQueryResolver.java 7 Aug 2003 18:03:21 -0000 1.16 @@ -121,6 +121,9 @@ */ public final class XPathQueryResolver extends SimpleConfigurable implements QueryResolver { + + private static final Log log = LogFactory.getLog(XPathQueryResolver.class); + private static final Key[] EmptyKeys = new Key[0]; private static final Key[][] EmptyKeySet = new Key[0][0]; private static final String WILDCARD = "*"; @@ -130,8 +133,6 @@ private static final String AUTOINDEX = "autoindex"; public static final String STYLE_XPATH = "XPath"; - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); // Maps Xalan Comparisons To IndexQuery private static final int[] OpMap = 1.12 +16 -17 xml-xindice/java/src/org/apache/xindice/core/request/URIMapper.java Index: URIMapper.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/request/URIMapper.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- URIMapper.java 1 Aug 2003 19:40:19 -0000 1.11 +++ URIMapper.java 7 Aug 2003 18:03:22 -0000 1.12 @@ -89,6 +89,8 @@ public final class URIMapper extends URLConnection implements Poolable { + private static final Log log = LogFactory.getLog(URIMapper.class); + public static final int UNKNOWN = -1; public static final int APPLICATION = 1; public static final int COLLECTION = 2; @@ -96,8 +98,6 @@ public static final String DEFAULT_ENCODING = "UTF-8"; - private static Log log = LogFactory.getLog("org.apache.xindice.core"); - private ObjectPool pool = null; private String uri = null; private int type = 0; @@ -118,7 +118,8 @@ private String urlresult = null; // Holds the value of the URL resolution results (XML doc or XMLObject call results ) private boolean inputstreamset = false; // Flag to tell if the input stream has been initialized - /** Constructor for creating URIMapper instance using a standard URL + /** + * Constructor for creating URIMapper instance using a standard URL */ public URIMapper(URL u) { super(u); @@ -130,29 +131,31 @@ } } - /** Constructor for older URIMapper instances + /** + * Constructor for older URIMapper instances */ public URIMapper(String uri) throws XindiceException { super(null); setURI(uri); } - /** Constructor for older URIMapper instances + /** + * Constructor for older URIMapper instances */ public URIMapper() { super(null); } /** - Opens a communications link to the resource referenced by this URL, - if such a connection has not already been established. + * Opens a communications link to the resource referenced by this URL, + * if such a connection has not already been established. */ public void connect() { this.connected = true; } /** - Returns an input stream that reads from this open connection. + * Returns an input stream that reads from this open connection. */ public InputStream getInputStream() throws IOException { @@ -195,8 +198,7 @@ /** * Returns the value of the content-encoding header field. - * Returns: - * the content encoding of the resource that the URL references, or null if not known. + * @return the content encoding of the resource that the URL references, or null if not known. */ public String getContentEncoding() { return DEFAULT_ENCODING; @@ -204,8 +206,7 @@ /** * Returns the value of the content-type header field. - * Returns: - * the content type of the resource that the URL references, or null if not known. + * @return the content type of the resource that the URL references, or null if not known. */ public String getContentType() { // Return the docuement's content type, for now this can only be "text/xml" @@ -214,8 +215,7 @@ /** * Returns the value of the content-length header field. - * Returns: - * the content length of the resource that this connection's URL references, or -1 if the content length is not known. + * @return the content length of the resource that this connection's URL references, or -1 if the content length is not known. */ public int getContentLength() { // Check to see if this document has already been resolved, if not call getInputStream @@ -233,8 +233,7 @@ /** * Returns the value of the last-modified header field. The result is the number of milliseconds since January 1, 1970 GMT. - * Returns: - * the date the resource referenced by this URLConnection was last modified, or 0 if not known. + * @return the date the resource referenced by this URLConnection was last modified, or 0 if not known. */ public long getLastModified() { // For now this functionality is not available, return 0 1.10 +4 -4 xml-xindice/java/src/org/apache/xindice/core/xupdate/XUpdateQueryResolver.java Index: XUpdateQueryResolver.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/xupdate/XUpdateQueryResolver.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- XUpdateQueryResolver.java 1 Aug 2003 19:40:19 -0000 1.9 +++ XUpdateQueryResolver.java 7 Aug 2003 18:03:22 -0000 1.10 @@ -87,14 +87,14 @@ * XUpdateQueryResolver */ public class XUpdateQueryResolver extends SimpleConfigurable implements QueryResolver { + + private static Log log = LogFactory.getLog(XUpdateQueryResolver.class); + private static final String XUPDATE_XPATH_PROP = "org.xmldb.common.xml.queries.XPathQueryFactory"; private static final String XUPDATE_XPATH_IMPL = "org.apache.xindice.core.xupdate.XPathQueryFactoryImpl"; - static { System.setProperty(XUPDATE_XPATH_PROP, XUPDATE_XPATH_IMPL); } - - private static Log log = LogFactory.getLog("org.apache.xindice.core"); public static final String STYLE_XUPDATE = "XUpdate"; 1.3 +24 -22 xml-xindice/java/src/org/apache/xindice/server/ManagedServer.java Index: ManagedServer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/server/ManagedServer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ManagedServer.java 1 Aug 2003 19:40:19 -0000 1.2 +++ ManagedServer.java 7 Aug 2003 18:03:22 -0000 1.3 @@ -83,37 +83,39 @@ * @version $Revision$ - $Date$ */ public class ManagedServer { - protected Log _log = LogFactory.getLog(getClass()); - protected Database _db = null; - protected boolean _running = false; + + private static final Log log = LogFactory.getLog(ManagedServer.class); + + private Database db = null; + private boolean running = false; + public synchronized void start() throws Exception { - if (!_running) { + if (!running) { configure(); - _running = true; + running = true; } else { - _log.warn("Start called on a running server, ignored"); + log.warn("Start called on a running server, ignored"); } } public void stop() throws Exception { - if (_running) { - _db.close(); - _db = null; + if (running) { + db.close(); + db = null; } else { - _log.warn("Stop called on a stopped server, ignored"); + log.warn("Stop called on a stopped server, ignored"); } } public void configure() throws FileNotFoundException, XindiceException { - _db = Database.getDatabase(loadConfiguration()); - - if (null == _db) { - _log.fatal("Unable to configure database"); + db = Database.getDatabase(loadConfiguration()); + if (null == db) { + log.fatal("Unable to configure database"); throw new XindiceException("Unable to configure database"); - } else if (_log.isInfoEnabled()) { - _log.info("Database name: '" + _db.getName() + "'"); + } else if (log.isInfoEnabled()) { + log.info("Database name: '" + db.getName() + "'"); } } @@ -121,15 +123,15 @@ Configuration config; String configFile = System.getProperty(Xindice.PROP_XINDICE_CONFIGURATION); if (configFile != null && !configFile.equals("")) { - if (_log.isInfoEnabled()) { - _log.info("Specified configuration file: '" + configFile + "'"); + if (log.isInfoEnabled()) { + log.info("Specified configuration file: '" + configFile + "'"); } FileInputStream configXMLFile = new FileInputStream(new File(configFile)); config = new Configuration(DOMParser.toDocument(configXMLFile), false); } else { - if (_log.isInfoEnabled()) { - _log.info("No configuration file specified, going with the default configuration"); + if (log.isInfoEnabled()) { + log.info("No configuration file specified, going with the default configuration"); } config = new Configuration(DOMParser.toDocument(Xindice.DEFAULT_CONFIGURATION), false); } 1.19 +3 -2 xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java Index: XindiceServlet.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- XindiceServlet.java 1 Aug 2003 19:40:19 -0000 1.18 +++ XindiceServlet.java 7 Aug 2003 18:03:22 -0000 1.19 @@ -92,8 +92,9 @@ */ public class XindiceServlet extends HttpServlet { + private static final Log log = LogFactory.getLog(XindiceServlet.class); + private static final String DEFAULT_XMLRPC_DRIVER = "xerces"; - protected static Log log = LogFactory.getLog("org.apache.xindice.servlet"); protected Database database; protected XmlRpcServer xmlrpcServer; 1.21 +540 -540 xml-xindice/java/src/org/apache/xindice/tools/XMLTools.java Index: XMLTools.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/XMLTools.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- XMLTools.java 5 Aug 2003 08:47:00 -0000 1.20 +++ XMLTools.java 7 Aug 2003 18:03:22 -0000 1.21 @@ -88,6 +88,9 @@ * user Xindice management flexibility within the current Database. */ public class XMLTools { + + private static final Log log = LogFactory.getLog(XMLTools.class); + public static final String COLLECTION = "collection"; public static final String EXTENSION = "extension"; public static final String FILE_PATH = "filePath"; @@ -111,519 +114,516 @@ public static final String NAMESPACES = "namespaces"; public static final String IMPL_CLASS = "implClass"; - private static Log log = LogFactory.getLog("org.apache.xindice.XMLTools"); + private Hashtable table; + protected String location = null; + private boolean initialized = false; + private static boolean verbose = false; + + private Document commandsDocument = null; + protected NodeList commandsList = null; + + + public static void main(String[] args) { + try { + new XMLTools().process(args); + } catch (Exception e) { + System.out.println(e.getMessage()); + if (verbose == true) { + e.printStackTrace(System.err); + } + } + } + + /** Constructor for XMLTools, includes default variables for the command line + */ + public XMLTools() { + table = new Hashtable(); + // defaults for command switches + table.put(FILE_PATH, ""); + table.put(EXTENSION, ""); + table.put(QUERY, ""); + table.put(AUTO_KEY, ""); + table.put(VERBOSE, "false"); + } + + protected void initCommandsList() { + // Get all user elements + NodeList list = getCommandsDocument().getElementsByTagName("user"); + + if (list.getLength() > 0) { + // Retrieve the index of the first element (<user>) + Element node = (Element) list.item(0); + // get all command children from the user element + list = node.getElementsByTagName("command"); + } + + // Return the list generated + commandsList = list; + } - private Hashtable table; - protected String location = null; - private boolean initialized = false; - private static boolean verbose = false; - - public static void main(String[] args) { - try { - new XMLTools().process(args); - } - catch (Exception e) { - System.out.println(e.getMessage()); - if (verbose == true) { - e.printStackTrace(System.err); - } - } - } - - /** Constructor for XMLTools, includes default variables for the command line - */ - public XMLTools() { - table = new Hashtable(); - // defaults for command switches - table.put( FILE_PATH, "" ); - table.put( EXTENSION, "" ); - table.put( QUERY, "" ); - table.put( AUTO_KEY, "" ); - table.put( VERBOSE, "false" ); - } - - protected void initCommandsList() { - // Get all user elements - NodeList list = getCommandsDocument().getElementsByTagName("user"); - - if ( list.getLength() > 0 ) { - // Retrieve the index of the first element (<user>) - Element node = (Element) list.item(0); - // get all command children from the user element - list = node.getElementsByTagName( "command" ); - } - - // Return the list generated - commandsList = list; - } - - /** Return true if this class has admin access - */ - public boolean isAdmin() { - return false; - } - - /** + /** Return true if this class has admin access + */ + public boolean isAdmin() { + return false; + } + + /** * Carries out necessary initialization of this class. **/ public void init() throws XindiceException, FileNotFoundException { - if ( !initialized ) { - initCommandsDocument(); - initCommandsList(); - initialized = true; - } + if (!initialized) { + initCommandsDocument(); + initCommandsList(); + initialized = true; + } } + /** * Carries out the initialization of the Commands Document. **/ protected void initCommandsDocument() throws XindiceException, FileNotFoundException { - // Absolute path to the commands.xml file, relative to $XINDICE_HOME - File xindiceHome = new File( System.getProperty( Xindice.PROP_XINDICE_HOME, "." ) ); - File commandsFile = new File( xindiceHome, "config/commands.xml" ); + // Absolute path to the commands.xml file, relative to $XINDICE_HOME + File xindiceHome = new File(System.getProperty(Xindice.PROP_XINDICE_HOME, ".")); + File commandsFile = new File(xindiceHome, "config/commands.xml"); - commandsDocument = DOMParser.toDocument( new FileInputStream( commandsFile ) ); + commandsDocument = DOMParser.toDocument(new FileInputStream(commandsFile)); } - private Document commandsDocument = null; /** * Returns the Commands Document use for configuration. **/ protected Document getCommandsDocument() { - return commandsDocument; + return commandsDocument; } - - protected NodeList commandsList = null; /** * Returns the <command> elements from the Commands Document this * tool can execute. **/ protected NodeList getCommands() { - return commandsList; + return commandsList; } - /** - * The Process function is designed for the implementation of the - * command line tools, as well as, making the command line easier - * to use. - **/ - public void process(String[] args) throws XindiceException, Exception { - try { - init(); - parseArguments(args); + /** + * The Process function is designed for the implementation of the + * command line tools, as well as, making the command line easier + * to use. + **/ + public void process(String[] args) throws XindiceException, Exception { + try { + init(); + parseArguments(args); - if ( !execute() ) { - printHelp(); - } - } catch (IllegalArgumentException e) { - printHelp(); - throw new XindiceException("ERROR : " + e.getMessage(), e); - } catch (NoSuchElementException e) { - throw new NoSuchElementException("ERROR : " + e + " Switch found. Parameter missing."); - } catch (NullPointerException e) { - e.printStackTrace(System.err); - throw new NullPointerException("ERROR : " + e); - } catch (Exception e) { - e.printStackTrace(System.err); - throw new XindiceException("ERROR : " + e.getMessage(), e); - } - } - - /** - * Parses and validated the arguments of the command line. The arguments are - * stored into the <tt>table</tt> array. - * - * @exception IllegalArgumentException if an error is found - */ - protected void parseArguments(String[] args) - throws IllegalArgumentException { - // parsing arguments for the command tools - ArgTokenizer at = new ArgTokenizer(args); - - if ( !at.hasMoreTokens() ) { - throw new IllegalArgumentException("No argument found"); - } - - // Action should always be the second token, if not there show help - table.put( ACTION , at.nextToken() ); - - // Loop over remaining command line arguments, populating hashtable - while ( at.hasMoreTokens() ) { - String token = at.nextToken(); - - if ( token.equalsIgnoreCase( "-c" ) || token.equalsIgnoreCase( "--collection" ) ) { - String colname = at.nextSwitchToken(); - if ( !colname.startsWith( "/" ) && - !colname.startsWith( "xmldb:xindice" ) ) { - throw new IllegalArgumentException( "The name of a collection must start with '/'" ); - } - table.put( COLLECTION, colname ); - } else if ( token.equalsIgnoreCase("-e") || token.equalsIgnoreCase("--extension") ) { - table.put( EXTENSION, at.nextSwitchToken()); - } else if ( token.equalsIgnoreCase("-f") || token.equalsIgnoreCase("--filepath") ) { - table.put( FILE_PATH, at.nextSwitchToken()); - } else if ( token.equalsIgnoreCase("-h") || token.equalsIgnoreCase("--help") ) { - table.put( ACTION, "help"); - } else if ( token.equalsIgnoreCase("-n") || token.equalsIgnoreCase("--nameOf") ) { - table.put( NAME_OF, at.nextSwitchToken()); - } else if ( token.equalsIgnoreCase("-p") || token.equalsIgnoreCase("--pattern") ) { - table.put( PATTERN, at.nextSwitchToken()); - } else if ( token.equalsIgnoreCase("-q") || token.equalsIgnoreCase("--query") ) { - table.put( QUERY, at.nextSwitchToken()); - } else if ( token.equalsIgnoreCase("-u") || token.equalsIgnoreCase("--uri") ) { - table.put( URI, at.nextSwitchToken()); - } else if ( token.equalsIgnoreCase("-v") || token.equalsIgnoreCase("--verbose") ) { - table.put( VERBOSE, "true"); - } else if ( token.equalsIgnoreCase("-l") || token.equalsIgnoreCase("--localdb") ) { - table.put( LOCAL, "true"); - } else if ( token.equalsIgnoreCase("-d") || token.equalsIgnoreCase("--dbconfig") ) { - String configFile = at.nextSwitchToken(); - if (!new File(configFile).isAbsolute()) { - configFile = new File(System.getProperty("user.dir"), configFile).getAbsolutePath(); - } - System.setProperty(Xindice.PROP_XINDICE_CONFIGURATION, configFile); - table.put(DB_CONFIG, configFile); - } else if ( token.equalsIgnoreCase("-s") || token.equalsIgnoreCase("--namespaces") ) { - table.put(NAMESPACES, at.nextSwitchToken()); - // Index specific options - } else if ( token.equalsIgnoreCase("-t") || token.equalsIgnoreCase("--type") ) { - table.put( TYPE, at.nextSwitchToken()); - } else if ( token.equalsIgnoreCase("+trim") ) { - if ( !table.containsKey( TYPE ) ) { - table.put( TYPE, "trimmed"); + if (!execute()) { + printHelp(); } - } else if ( token.equalsIgnoreCase("-trim") ) { - if ( !table.containsKey( TYPE ) ) { - table.put( TYPE, "string"); + } catch (IllegalArgumentException e) { + printHelp(); + throw new XindiceException("ERROR : " + e.getMessage(), e); + } catch (NoSuchElementException e) { + throw new NoSuchElementException("ERROR : " + e + " Switch found. Parameter missing."); + } catch (NullPointerException e) { + e.printStackTrace(System.err); + throw new NullPointerException("ERROR : " + e); + } catch (Exception e) { + e.printStackTrace(System.err); + throw new XindiceException("ERROR : " + e.getMessage(), e); + } + } + + /** + * Parses and validated the arguments of the command line. The arguments are + * stored into the <tt>table</tt> array. + * + * @exception IllegalArgumentException if an error is found + */ + protected void parseArguments(String[] args) + throws IllegalArgumentException { + // parsing arguments for the command tools + ArgTokenizer at = new ArgTokenizer(args); + + if (!at.hasMoreTokens()) { + throw new IllegalArgumentException("No argument found"); + } + + // Action should always be the second token, if not there show help + table.put(ACTION, at.nextToken()); + + // Loop over remaining command line arguments, populating hashtable + while (at.hasMoreTokens()) { + String token = at.nextToken(); + + if (token.equalsIgnoreCase("-c") || token.equalsIgnoreCase("--collection")) { + String colname = at.nextSwitchToken(); + if (!colname.startsWith("/") && + !colname.startsWith("xmldb:xindice")) { + throw new IllegalArgumentException("The name of a collection must start with '/'"); + } + table.put(COLLECTION, colname); + } else if (token.equalsIgnoreCase("-e") || token.equalsIgnoreCase("--extension")) { + table.put(EXTENSION, at.nextSwitchToken()); + } else if (token.equalsIgnoreCase("-f") || token.equalsIgnoreCase("--filepath")) { + table.put(FILE_PATH, at.nextSwitchToken()); + } else if (token.equalsIgnoreCase("-h") || token.equalsIgnoreCase("--help")) { + table.put(ACTION, "help"); + } else if (token.equalsIgnoreCase("-n") || token.equalsIgnoreCase("--nameOf")) { + table.put(NAME_OF, at.nextSwitchToken()); + } else if (token.equalsIgnoreCase("-p") || token.equalsIgnoreCase("--pattern")) { + table.put(PATTERN, at.nextSwitchToken()); + } else if (token.equalsIgnoreCase("-q") || token.equalsIgnoreCase("--query")) { + table.put(QUERY, at.nextSwitchToken()); + } else if (token.equalsIgnoreCase("-u") || token.equalsIgnoreCase("--uri")) { + table.put(URI, at.nextSwitchToken()); + } else if (token.equalsIgnoreCase("-v") || token.equalsIgnoreCase("--verbose")) { + table.put(VERBOSE, "true"); + } else if (token.equalsIgnoreCase("-l") || token.equalsIgnoreCase("--localdb")) { + table.put(LOCAL, "true"); + } else if (token.equalsIgnoreCase("-d") || token.equalsIgnoreCase("--dbconfig")) { + String configFile = at.nextSwitchToken(); + if (!new File(configFile).isAbsolute()) { + configFile = new File(System.getProperty("user.dir"), configFile).getAbsolutePath(); + } + System.setProperty(Xindice.PROP_XINDICE_CONFIGURATION, configFile); + table.put(DB_CONFIG, configFile); + } else if (token.equalsIgnoreCase("-s") || token.equalsIgnoreCase("--namespaces")) { + table.put(NAMESPACES, at.nextSwitchToken()); + // Index specific options + } else if (token.equalsIgnoreCase("-t") || token.equalsIgnoreCase("--type")) { + table.put(TYPE, at.nextSwitchToken()); + } else if (token.equalsIgnoreCase("+trim")) { + if (!table.containsKey(TYPE)) { + table.put(TYPE, "trimmed"); + } + } else if (token.equalsIgnoreCase("-trim")) { + if (!table.containsKey(TYPE)) { + table.put(TYPE, "string"); + } + } else if (token.equalsIgnoreCase("--pagesize")) { + table.put(PAGE_SIZE, at.nextSwitchToken()); + } else if (token.equalsIgnoreCase("--maxkeysize")) { + table.put(MAX_KEY_SIZE, at.nextSwitchToken()); } - } else if ( token.equalsIgnoreCase("--pagesize") ) { - table.put( PAGE_SIZE, at.nextSwitchToken()); - } else if ( token.equalsIgnoreCase("--maxkeysize") ) { - table.put( MAX_KEY_SIZE, at.nextSwitchToken()); - } - } // End of while loop - } + } // End of while loop + } - /** + /** * This method is to carry out execution, after instance variables being setup by process( args ) - **/ + */ public boolean execute() throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception { - init(); - String action = (String) table.get( ACTION ); + init(); + String action = (String) table.get(ACTION); - // get command class name - String commandClass = null; - if ( action != null ) { - // search for the tool Class associated with the given action - NodeList commands = getCommands(); - for ( int i = 0; i < commands.getLength(); i++ ) { - Element e = (Element) commands.item( i ); - if ( action.equals( e.getAttribute( "switch" ) ) || - action.equals( e.getAttribute( "name" ) ) ) { - commandClass = e.getAttribute( "class" ); - } - } - } - - if ( commandClass != null ) { - try { - // register Xindice Database with xml:db - Database db = new DatabaseImpl(); - - DatabaseManager.registerDatabase( db ); - - // execute command class - Command command = (Command)Class.forName( commandClass ).newInstance(); - command.execute( table ); - return true; - } catch (XMLDBException e) { - System.err.println( "XMLDB Exception with code " + e.errorCode ); - if (table.get(VERBOSE).equals("true")) { - e.printStackTrace(System.err); - } - return false; - } catch (Exception e) { - System.err.println("ERROR : " + e.getMessage() ); - - if (table.get(VERBOSE).equals("true")) { - e.printStackTrace(System.err); + // get command class name + String commandClass = null; + if (action != null) { + // search for the tool Class associated with the given action + NodeList commands = getCommands(); + for (int i = 0; i < commands.getLength(); i++) { + Element e = (Element) commands.item(i); + if (action.equals(e.getAttribute("switch")) || + action.equals(e.getAttribute("name"))) { + commandClass = e.getAttribute("class"); + } + } + } + + if (commandClass != null) { + try { + // register Xindice Database with xml:db + Database db = new DatabaseImpl(); + + DatabaseManager.registerDatabase(db); + + // execute command class + Command command = (Command) Class.forName(commandClass).newInstance(); + command.execute(table); + return true; + } catch (XMLDBException e) { + System.err.println("XMLDB Exception with code " + e.errorCode); + if (table.get(VERBOSE).equals("true")) { + e.printStackTrace(System.err); + } + return false; + } catch (Exception e) { + System.err.println("ERROR : " + e.getMessage()); + + if (table.get(VERBOSE).equals("true")) { + e.printStackTrace(System.err); + } + return false; } - return false; - } - } - - return false; - } - - - - public boolean handleOption(String option, ArgTokenizer at) { - return false; - } - - /** - * setAction sets the action type that will be passed to the command line. - * - * @param actionType The action value - */ - public void setAction(String actionType) { - table.put(XMLTools.ACTION, actionType); - } - - /** - * getAction returns the action type that will be passed to the command line - * tool. - * - * @return The action value - */ - public String getAction() { - return (String)table.get(XMLTools.ACTION); - } - - /** - * setCollectionName sets the collection name that will be passed - * to the command line. - * - * @param collectionName The collection value - */ - public void setCollectionName(String collectionName) { - table.put(COLLECTION, collectionName); - } - - /** - * getCollectionName returns the collection name that will be passed - * to the command line tool. - * - * @return The collection value - */ - public String getCollectionName() { - return (String)table.get(COLLECTION); - } - - /** - * setDocumentName sets the document that will be passed to the - * command line tool. - * - * @param documentName The docName value - */ - public void setDocumentName(String documentName) { - table.put(XMLTools.NAME_OF, documentName); - } - - /** - * getDocumentName returns the document that will be passed to the - * command line tool. - * - * @return The docName value - */ - public String getDocumentName() { - return (String)table.get(XMLTools.NAME_OF); - } - - /** - * setQuery sets the Query variable for Document Query from the command line. - * - * @param query - The query string - */ - public void setQuery(String query ) { - table.put(XMLTools.QUERY, query); - } - - /** - * getQuery returns the Query for Document passed to the command line tool. - */ - public String getQuery() { - return (String)table.get(XMLTools.QUERY); - } - - /** - * setName sets the name for XMLObjects passed to the command line tool. - * - * @param name The docName value - */ - public void setName(String name) { - table.put(XMLTools.NAME_OF, name); - } - - /** - * getName returns the name for XMLObjects that will be passed to the - * command line tool. - * - * @return The nameOf value - */ - public String getName() { - return (String)table.get(XMLTools.NAME_OF); - } - - /** - * setDatabaseServer sets the Database server name that will be - * passed to the command line tool. - * - * @param appName The dbServ value - */ - public void setDatabaseServer(String appName) { - table.put(XMLTools.DB_SERVER, appName); - } - - /** - * getDatabaseServer returns the Database server that will be - * passed to the command line tool. - * - * @return The dbServ value - */ - public String getDatabaseServer() { - return (String)table.get(XMLTools.DB_SERVER); - } - - /** - * setPort sets the port that will passed to the command line tool. - * - * @param portName The port value - */ - public void setPort(String portName) { - table.put(XMLTools.PORT, portName); - } - - /** - * getPort returns the port that will be passed to the command line tool. - * - * @return The port value - */ - public String getPort() { - return (String)table.get(XMLTools.PORT); - } - - /** - * setHost sets the host that will passed to the command line tool. - * - * @param hostName The host value - */ - public void setHost(String hostName) { - table.put(HOST, hostName); - } - - /** - * getPort returns the host that will be passed to the command line tool. - * - * @return The host value - */ - public String getHost() { - return (String)table.get(HOST); - } - - /** - * setFilePath sets the file path that will passed to the command line tool. - * - * @param fPath The filePath value - */ - public void setFilePath(String fPath) { - table.put(XMLTools.FILE_PATH, fPath); - } - - /** - * getFilePath returns the file path that will be passed to the command - * - * @return The filePath value - */ - public String getFilePath() { - return (String)table.get(XMLTools.FILE_PATH); - } - - /** - * setURI sets the database URI (protocol://host:port/name) that - * will be passed to the command line - * - * @param URI The URI for the database - */ - public void setURI(String URI) { - table.put(XMLTools.URI, URI); - } - - /** - * getURI gets returns the database URI (protocol://host:port/name) - * that will be passed to the command line tool - * - * @return The URI for the database - */ - public String getURI() { - return (String)table.get(XMLTools.URI); - } - - /** - * setImplementClass sets the implemented class path that will be passed - * to the command line tool. - * - * @param imClassName The implClass value - */ - public void setImplementClass(String imClassName) { - table.put(XMLTools.IMPL_CLASS, imClassName); - } - - /** - * getImplementClass returns the implmented class path that will be passed - * to the command line tool. - * - * @return The implClass value - */ - public String getImplementClass() { - return (String)table.get(XMLTools.IMPL_CLASS); - } - - - /** - * The following Security methods are simply a starting point. User names and - * their related passwords will not be this simple. Until Encryption for - * Passwords are developed, and KeyStorage is set-up, this will do for now. - * In the future, these methods will change as needed to be more efficient - * for Xindice. - */ - - - /** - * setUser sets the user that will be passed to the command line tool and - * will be used in Security issues. - * - * @param userName The user value - */ - public void setUser(String userName) { - table.put(XMLTools.USER, userName); - } - - /** - * getUser returns the user that will be passed to the command line tool and - * will be used in Security issues. - * - * @return The user value - */ - public String getUser() { - return (String)table.get(XMLTools.USER); - } - - /** - * setPassword sets the password that will be passed to the command line tool - * and will be used in conjunction with the userName value. - * - * @param pswd The passwrd value - */ - public void setPassword(String pswd) { - table.put(PASSWORD, pswd); - } - - /** - * getPassword returns the password that will be passed to the command line - * tool and will be used in conjunction with the userName value. - * - * @return The password value - */ - public String getPassword() { - return (String)table.get(PASSWORD); - } + } + return false; + } + + + public boolean handleOption(String option, ArgTokenizer at) { + return false; + } + + /** + * setAction sets the action type that will be passed to the command line. + * + * @param actionType The action value + */ + public void setAction(String actionType) { + table.put(XMLTools.ACTION, actionType); + } + + /** + * getAction returns the action type that will be passed to the command line + * tool. + * + * @return The action value + */ + public String getAction() { + return (String) table.get(XMLTools.ACTION); + } + + /** + * setCollectionName sets the collection name that will be passed + * to the command line. + * + * @param collectionName The collection value + */ + public void setCollectionName(String collectionName) { + table.put(COLLECTION, collectionName); + } + + /** + * getCollectionName returns the collection name that will be passed + * to the command line tool. + * + * @return The collection value + */ + public String getCollectionName() { + return (String) table.get(COLLECTION); + } + + /** + * setDocumentName sets the document that will be passed to the + * command line tool. + * + * @param documentName The docName value + */ + public void setDocumentName(String documentName) { + table.put(XMLTools.NAME_OF, documentName); + } + + /** + * getDocumentName returns the document that will be passed to the + * command line tool. + * + * @return The docName value + */ + public String getDocumentName() { + return (String) table.get(XMLTools.NAME_OF); + } + + /** + * setQuery sets the Query variable for Document Query from the command line. + * + * @param query - The query string + */ + public void setQuery(String query) { + table.put(XMLTools.QUERY, query); + } + + /** + * getQuery returns the Query for Document passed to the command line tool. + */ + public String getQuery() { + return (String) table.get(XMLTools.QUERY); + } + + /** + * setName sets the name for XMLObjects passed to the command line tool. + * + * @param name The docName value + */ + public void setName(String name) { + table.put(XMLTools.NAME_OF, name); + } + + /** + * getName returns the name for XMLObjects that will be passed to the + * command line tool. + * + * @return The nameOf value + */ + public String getName() { + return (String) table.get(XMLTools.NAME_OF); + } + + /** + * setDatabaseServer sets the Database server name that will be + * passed to the command line tool. + * + * @param appName The dbServ value + */ + public void setDatabaseServer(String appName) { + table.put(XMLTools.DB_SERVER, appName); + } + + /** + * getDatabaseServer returns the Database server that will be + * passed to the command line tool. + * + * @return The dbServ value + */ + public String getDatabaseServer() { + return (String) table.get(XMLTools.DB_SERVER); + } + + /** + * setPort sets the port that will passed to the command line tool. + * + * @param portName The port value + */ + public void setPort(String portName) { + table.put(XMLTools.PORT, portName); + } + + /** + * getPort returns the port that will be passed to the command line tool. + * + * @return The port value + */ + public String getPort() { + return (String) table.get(XMLTools.PORT); + } + + /** + * setHost sets the host that will passed to the command line tool. + * + * @param hostName The host value + */ + public void setHost(String hostName) { + table.put(HOST, hostName); + } + + /** + * getPort returns the host that will be passed to the command line tool. + * + * @return The host value + */ + public String getHost() { + return (String) table.get(HOST); + } + + /** + * setFilePath sets the file path that will passed to the command line tool. + * + * @param fPath The filePath value + */ + public void setFilePath(String fPath) { + table.put(XMLTools.FILE_PATH, fPath); + } + + /** + * getFilePath returns the file path that will be passed to the command + * + * @return The filePath value + */ + public String getFilePath() { + return (String) table.get(XMLTools.FILE_PATH); + } + + /** + * setURI sets the database URI (protocol://host:port/name) that + * will be passed to the command line + * + * @param URI The URI for the database + */ + public void setURI(String URI) { + table.put(XMLTools.URI, URI); + } + + /** + * getURI gets returns the database URI (protocol://host:port/name) + * that will be passed to the command line tool + * + * @return The URI for the database + */ + public String getURI() { + return (String) table.get(XMLTools.URI); + } + + /** + * setImplementClass sets the implemented class path that will be passed + * to the command line tool. + * + * @param imClassName The implClass value + */ + public void setImplementClass(String imClassName) { + table.put(XMLTools.IMPL_CLASS, imClassName); + } + + /** + * getImplementClass returns the implmented class path that will be passed + * to the command line tool. + * + * @return The implClass value + */ + public String getImplementClass() { + return (String) table.get(XMLTools.IMPL_CLASS); + } + + + /** + * The following Security methods are simply a starting point. User names and + * their related passwords will not be this simple. Until Encryption for + * Passwords are developed, and KeyStorage is set-up, this will do for now. + * In the future, these methods will change as needed to be more efficient + * for Xindice. + */ + + + /** + * setUser sets the user that will be passed to the command line tool and + * will be used in Security issues. + * + * @param userName The user value + */ + public void setUser(String userName) { + table.put(XMLTools.USER, userName); + } + + /** + * getUser returns the user that will be passed to the command line tool and + * will be used in Security issues. + * + * @return The user value + */ + public String getUser() { + return (String) table.get(XMLTools.USER); + } + + /** + * setPassword sets the password that will be passed to the command line tool + * and will be used in conjunction with the userName value. + * + * @param pswd The passwrd value + */ + public void setPassword(String pswd) { + table.put(PASSWORD, pswd); + } + + /** + * getPassword returns the password that will be passed to the command line + * tool and will be used in conjunction with the userName value. + * + * @return The password value + */ + public String getPassword() { + return (String) table.get(PASSWORD); + } public void printHelp() { - NodeList list = getCommands(); + NodeList list = getCommands(); // This method relies on two things to format the output for help // Method isAdmin() - Tells us if this is an admin instance, used to hide certain output @@ -636,68 +636,68 @@ // Show the header and switch commands - System.out.println(); - System.out.println("Xindice Command Tools v" + Xindice.Version); - System.out.println(); - System.out.println("Format: xindice action [switch] [parameter]"); - System.out.println(); - System.out.println("Where: [switch] implements:"); - System.out.println(" -c " + "Collection context (must always be specified)"); - System.out.println(" -e " + "File extension for multiple documents"); - System.out.println(" -f " + "File path for document retrieval and storage"); - System.out.println(" -n " + "Name"); - System.out.println(" -p " + "Index pattern"); - System.out.println(" -q " + "Query string"); - System.out.println(" -s " + "Semi-colon delimited list of namespaces for query in "); - System.out.println(" the form prefix=namespace-uri"); - System.out.println(" -l " + "Use a local database rather then going over the network."); - System.out.println(" Should be combined with -d to specify the configuration to use."); - System.out.println(" -d " + "Path to the database configuration to use for the local "); - System.out.println(" database. Only applies if -l is specified."); - System.out.println(" -t " + "Specify the data type in collection index"); - System.out.println(" -v " + "Verbose"); - System.out.println(" --pagesize " + "Page size for file pages (default: 4096)"); - System.out.println(" --maxkeysize " + "The maximum size for file keys (default: 0=none)"); - System.out.println(); - - System.out.println("\nActions:\n"); - System.out.println(" xindice [parameter], etc...\n"); - - // Show all elements with helpclass=document - - // Loop over the commands, printing test from description attribute - for (int i=0; i < list.getLength(); i++) { - helpClass = ((Element)list.item(i)).getAttribute("helpclass") ; - - if ( helpClass.equals("document") ) { - desc = ((Element)list.item(i)).getAttribute("description"); - cmdswitch = ((Element)list.item(i)).getAttribute("switch"); - System.out.println(" " + StringUtilities.leftJustify(cmdswitch, 13) + desc ); - } - } - - // Loop over the commands, printing text from description attribute - for (int i=0; i < list.getLength(); i++) { - helpClass = ((Element)list.item(i)).getAttribute("helpclass") ; - - if ( helpClass.equals("security") ) { - desc = ((Element)list.item(i)).getAttribute("description"); - cmdswitch = ((Element)list.item(i)).getAttribute("switch"); - System.out.println(" " + StringUtilities.leftJustify(cmdswitch, 13) + desc ); - } - } - - System.out.println("\nExamples:\n"); - - System.out.println(" xindice ad -c /db/test -f /tmp/xmldocument -n myxmldocument"); - System.out.println(" xindice dd -c /db/test -n myxmldocument"); - System.out.println(" xindice rd -c /db/test/ocs -f a:\\file.xml -n file.xml"); - System.out.println(" xindice xpath -c /db/test/ocs -q test"); - System.out.println(" xindice xpath -c /db/test -s a=http://somedomain.com/schema.xsd -q /a:foo"); - System.out.println(" xindice xupdate -c /db/test -f /path/to/xupdate.xml"); - System.out.println(" xindice xupdate -c /db/test -n document-to-update.xml -f /path/to/xupdate.xml"); - System.out.println(); - System.out.println("For more information, please read the Xindice - Tools Reference Guide"); - System.out.println(); - } + System.out.println(); + System.out.println("Xindice Command Tools v" + Xindice.Version); + System.out.println(); + System.out.println("Format: xindice action [switch] [parameter]"); + System.out.println(); + System.out.println("Where: [switch] implements:"); + System.out.println(" -c " + "Collection context (must always be specified)"); + System.out.println(" -e " + "File extension for multiple documents"); + System.out.println(" -f " + "File path for document retrieval and storage"); + System.out.println(" -n " + "Name"); + System.out.println(" -p " + "Index pattern"); + System.out.println(" -q " + "Query string"); + System.out.println(" -s " + "Semi-colon delimited list of namespaces for query in "); + System.out.println(" the form prefix=namespace-uri"); + System.out.println(" -l " + "Use a local database rather then going over the network."); + System.out.println(" Should be combined with -d to specify the configuration to use."); + System.out.println(" -d " + "Path to the database configuration to use for the local "); + System.out.println(" database. Only applies if -l is specified."); + System.out.println(" -t " + "Specify the data type in collection index"); + System.out.println(" -v " + "Verbose"); + System.out.println(" --pagesize " + "Page size for file pages (default: 4096)"); + System.out.println(" --maxkeysize " + "The maximum size for file keys (default: 0=none)"); + System.out.println(); + + System.out.println("\nActions:\n"); + System.out.println(" xindice [parameter], etc...\n"); + + // Show all elements with helpclass=document + + // Loop over the commands, printing test from description attribute + for (int i = 0; i < list.getLength(); i++) { + helpClass = ((Element) list.item(i)).getAttribute("helpclass"); + + if (helpClass.equals("document")) { + desc = ((Element) list.item(i)).getAttribute("description"); + cmdswitch = ((Element) list.item(i)).getAttribute("switch"); + System.out.println(" " + StringUtilities.leftJustify(cmdswitch, 13) + desc); + } + } + + // Loop over the commands, printing text from description attribute + for (int i = 0; i < list.getLength(); i++) { + helpClass = ((Element) list.item(i)).getAttribute("helpclass"); + + if (helpClass.equals("security")) { + desc = ((Element) list.item(i)).getAttribute("description"); + cmdswitch = ((Element) list.item(i)).getAttribute("switch"); + System.out.println(" " + StringUtilities.leftJustify(cmdswitch, 13) + desc); + } + } + + System.out.println("\nExamples:\n"); + + System.out.println(" xindice ad -c /db/test -f /tmp/xmldocument -n myxmldocument"); + System.out.println(" xindice dd -c /db/test -n myxmldocument"); + System.out.println(" xindice rd -c /db/test/ocs -f a:\\file.xml -n file.xml"); + System.out.println(" xindice xpath -c /db/test/ocs -q test"); + System.out.println(" xindice xpath -c /db/test -s a=http://somedomain.com/schema.xsd -q /a:foo"); + System.out.println(" xindice xupdate -c /db/test -f /path/to/xupdate.xml"); + System.out.println(" xindice xupdate -c /db/test -n document-to-update.xml -f /path/to/xupdate.xml"); + System.out.println(); + System.out.println("For more information, please read the Xindice - Tools Reference Guide"); + System.out.println(); + } } 1.7 +2 -8 xml-xindice/java/src/org/apache/xindice/tools/command/Command.java Index: Command.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/Command.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Command.java 1 Aug 2003 19:40:20 -0000 1.6 +++ Command.java 7 Aug 2003 18:03:22 -0000 1.7 @@ -59,9 +59,6 @@ * $Id$ */ -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.util.Hashtable; /** @@ -82,8 +79,6 @@ public static final String XINDICE_VAL_INDEXER = "org.apache.xindice.core.indexer.ValueIndexer"; public static final String XINDICE_NAME_INDEXER = "org.apache.xindice.core.indexer.NameIndexer"; - protected static Log log = LogFactory.getLog("org.apache.xindice.core"); - //public boolean execute(Hashtable table, Database db) public abstract boolean execute(Hashtable table) throws Exception; @@ -104,5 +99,4 @@ } } } -} //interface Command - +} 1.9 +8 -3 xml-xindice/java/src/org/apache/xindice/tools/command/ListCollections.java Index: ListCollections.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/ListCollections.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ListCollections.java 4 Aug 2003 22:31:55 -0000 1.8 +++ ListCollections.java 7 Aug 2003 18:03:22 -0000 1.9 @@ -60,19 +60,24 @@ */ import org.apache.xindice.tools.XMLTools; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; import java.util.Hashtable; - /** - * ListCollections.java is designed to let the user list all Collections from a parent Collection or a nested Collection. + * ListCollections.java is designed to let the user list all Collections from + * a parent Collection or a nested Collection. * NOTE: Collection names are not returned in any specific order */ public class ListCollections extends Command { + + private static final Log log = LogFactory.getLog(ListCollections.class); + public boolean execute(Hashtable table) throws Exception { String[] colarray = null; 1.9 +7 -4 xml-xindice/java/src/org/apache/xindice/tools/command/XPathQuery.java Index: XPathQuery.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/XPathQuery.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- XPathQuery.java 1 Aug 2003 19:40:20 -0000 1.8 +++ XPathQuery.java 7 Aug 2003 18:03:22 -0000 1.9 @@ -60,6 +60,8 @@ */ import org.apache.xindice.tools.XMLTools; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; @@ -73,16 +75,17 @@ import java.util.StringTokenizer; /** - * SingleDocumentQuery is designed to enable the user/admin to XPathQuery a Collection for a Single Document. + * SingleDocumentQuery is designed to enable the user/admin to XPathQuery + * a Collection for a Single Document. */ public class XPathQuery extends Command { + private static final Log log = LogFactory.getLog(XPathQuery.class); + public boolean execute(Hashtable table) throws Exception { Collection col = null; - try { - if ((String) table.get(XMLTools.COLLECTION) == null) { System.out.println("ERROR : Collection name and switch required"); return false; 1.2 +7 -8 xml-xindice/java/src/org/apache/xindice/tools/command/XUpdate.java Index: XUpdate.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/XUpdate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- XUpdate.java 5 Aug 2003 08:47:00 -0000 1.1 +++ XUpdate.java 7 Aug 2003 18:03:22 -0000 1.2 @@ -59,22 +59,19 @@ * $Id$ */ +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.xindice.tools.XMLTools; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; -import org.xmldb.api.base.ResourceIterator; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.XMLResource; import org.xmldb.api.modules.XUpdateQueryService; -import java.util.Hashtable; -import java.util.StringTokenizer; -import java.io.File; import java.io.BufferedReader; +import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; +import java.util.Hashtable; /** @@ -84,6 +81,8 @@ * @author Kimbro Staken <[EMAIL PROTECTED]> */ public class XUpdate extends Command { + + private static final Log log = LogFactory.getLog(XUpdate.class); public boolean execute(Hashtable table) throws Exception { Collection col = null; 1.10 +7 -5 xml-xindice/java/src/org/apache/xindice/util/Configuration.java Index: Configuration.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/Configuration.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Configuration.java 1 Aug 2003 19:40:21 -0000 1.9 +++ Configuration.java 7 Aug 2003 18:03:22 -0000 1.10 @@ -82,16 +82,18 @@ */ public final class Configuration { + + private static final Log log = LogFactory.getLog(Configuration.class); + private static final Configuration[] EmptySet = new Configuration[0]; // commented out 2002-07-16: not used //private static final Map Modified = Collections.synchronizedMap(new HashMap()); // Temporary HACK - private static Log log = LogFactory.getLog("org.apache.xindice.util"); - private Element config = null; private boolean readOnly = true; + public Configuration(Element config, boolean readOnly) { this.config = config; this.readOnly = readOnly; @@ -319,7 +321,7 @@ * @return The attribute value */ public double getDoubleAttribute(String name) { - return getDoubleAttribute(name, (double) 0.0); + return getDoubleAttribute(name, 0.0D); } /** @@ -556,7 +558,7 @@ * @return The value */ public double getDoubleValue() { - return getDoubleValue((double) 0.0); + return getDoubleValue(0.0D); } /** 1.6 +4 -3 xml-xindice/java/src/org/apache/xindice/util/SymbolSerializer.java Index: SymbolSerializer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/SymbolSerializer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SymbolSerializer.java 1 Aug 2003 19:40:21 -0000 1.5 +++ SymbolSerializer.java 7 Aug 2003 18:03:22 -0000 1.6 @@ -78,6 +78,9 @@ */ public final class SymbolSerializer { + + private static final Log log = LogFactory.getLog(SymbolSerializer.class); + private static final SymbolTableSymbols hcSyms = SymbolTableSymbols.getInstance(); private static final DocumentImpl elemFactory = new DocumentImpl(); @@ -85,7 +88,6 @@ private long lastMod = 0; // Last time we caught a SymbolTable modification private byte[] symBytes = null; // Stores a byte representation of the SymbolTable - private static Log log = LogFactory.getLog("org.apache.xindice.util"); public SymbolSerializer(SymbolTable syms) { this.syms = syms; @@ -167,4 +169,3 @@ return lastMod; } } - 1.9 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/TextWriter.java Index: TextWriter.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/TextWriter.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- TextWriter.java 1 Aug 2003 19:40:21 -0000 1.8 +++ TextWriter.java 7 Aug 2003 18:03:22 -0000 1.9 @@ -84,9 +84,10 @@ public final class TextWriter { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(TextWriter.class); private Node node = null; + public TextWriter(Node node) throws DOMException { this.node = node; 1.7 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/dom/CharacterDataImpl.java Index: CharacterDataImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/CharacterDataImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CharacterDataImpl.java 1 Aug 2003 19:40:21 -0000 1.6 +++ CharacterDataImpl.java 7 Aug 2003 18:03:22 -0000 1.7 @@ -74,7 +74,8 @@ public abstract class CharacterDataImpl extends NodeImpl implements CharacterData { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(CharacterDataImpl.class); + public CharacterDataImpl() { } 1.8 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java Index: ContainerNodeImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ContainerNodeImpl.java 1 Aug 2003 19:40:21 -0000 1.7 +++ ContainerNodeImpl.java 7 Aug 2003 18:03:22 -0000 1.8 @@ -86,9 +86,10 @@ public abstract class ContainerNodeImpl extends NodeImpl { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(ContainerNodeImpl.class); protected NodeListImpl childNodes = new NodeListImpl(this); + public ContainerNodeImpl() { } 1.8 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/dom/DocumentImpl.java Index: DocumentImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/DocumentImpl.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DocumentImpl.java 1 Aug 2003 19:40:21 -0000 1.7 +++ DocumentImpl.java 7 Aug 2003 18:03:22 -0000 1.8 @@ -96,7 +96,7 @@ public final class DocumentImpl extends ContainerNodeImpl implements CompressedDocument, DBDocument, DocumentTraversal { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(DocumentImpl.class); private DocumentType docType = null; private String version = null; @@ -106,6 +106,7 @@ private boolean strictErrorChecking = false; private SymbolTable symbols = null; private boolean readOnly = false; + public DocumentImpl() { super(null, true); 1.11 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/dom/ElementImpl.java Index: ElementImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/ElementImpl.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ElementImpl.java 1 Aug 2003 19:40:21 -0000 1.10 +++ ElementImpl.java 7 Aug 2003 18:03:22 -0000 1.11 @@ -81,7 +81,7 @@ public final class ElementImpl extends ContainerNodeImpl implements Element { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(ElementImpl.class); private static final String SRC_NS = XMLNS_PREFIX + ":src"; private static final String SRC_COL = "src:" + NodeSource.SOURCE_COL; @@ -89,6 +89,7 @@ private NamedNodeMapImpl attributes = new NamedNodeMapImpl(this); private short symbolID = -1; + public ElementImpl() { } 1.6 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/dom/EntityReferenceImpl.java Index: EntityReferenceImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/EntityReferenceImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- EntityReferenceImpl.java 1 Aug 2003 19:40:21 -0000 1.5 +++ EntityReferenceImpl.java 7 Aug 2003 18:03:22 -0000 1.6 @@ -75,9 +75,10 @@ public final class EntityReferenceImpl extends NodeImpl implements EntityReference { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(EntityReferenceImpl.class); private short symbolID = -1; + public EntityReferenceImpl() { } 1.8 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/dom/ProcessingInstructionImpl.java Index: ProcessingInstructionImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/ProcessingInstructionImpl.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ProcessingInstructionImpl.java 1 Aug 2003 19:40:22 -0000 1.7 +++ ProcessingInstructionImpl.java 7 Aug 2003 18:03:22 -0000 1.8 @@ -75,7 +75,8 @@ public final class ProcessingInstructionImpl extends NodeImpl implements ProcessingInstruction { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(ProcessingInstructionImpl.class); + public ProcessingInstructionImpl() { } 1.6 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/jaxp/DocumentBuilderImpl.java Index: DocumentBuilderImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/jaxp/DocumentBuilderImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DocumentBuilderImpl.java 1 Aug 2003 19:40:22 -0000 1.5 +++ DocumentBuilderImpl.java 7 Aug 2003 18:03:22 -0000 1.6 @@ -82,11 +82,12 @@ public class DocumentBuilderImpl extends DocumentBuilder { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(DocumentBuilderImpl.class); private DOMParser parser = null; private ErrorHandler errors = null; private EntityResolver entities = null; + protected DocumentBuilderImpl() throws ParserConfigurationException { try { 1.21 +3 -2 xml-xindice/java/src/org/apache/xindice/xml/sax/SAXEventGenerator.java Index: SAXEventGenerator.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/sax/SAXEventGenerator.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- SAXEventGenerator.java 1 Aug 2003 19:40:22 -0000 1.20 +++ SAXEventGenerator.java 7 Aug 2003 18:03:22 -0000 1.21 @@ -91,7 +91,7 @@ public final class SAXEventGenerator implements XMLReader { - private static Log log = LogFactory.getLog("org.apache.xindice.xml"); + private static final Log log = LogFactory.getLog(SAXEventGenerator.class); /** * This is a SAX feature that controls how namespaces are reported in SAX. @@ -143,6 +143,7 @@ private boolean interrupt = false; static final int XMLNS_MAP_INCREMENT = 5; + public SAXEventGenerator(SymbolTable symbols, byte[] data) { this.symbols = symbols;