vladimir 2003/08/08 22:01:56
Modified: java/src/org/apache/xindice/core MetaSystemCollection.java FaultCodes.java DocumentCache.java Collection.java java/src/org/apache/xindice/xml SymbolTable.java NamespaceMap.java XMLCompressedInput.java TextWriter.java java/src/org/apache/xindice/xml/dom ContainerNodeImpl.java DOMCompressor.java NodeImpl.java DOMParser.java NamedNodeMapImpl.java EntityReferenceImpl.java DOMImplementationImpl.java DocumentImpl.java CharacterDataImpl.java ElementImpl.java AttrImpl.java java/src/org/apache/xindice/client/xmldb/resources XMLResourceImpl.java java/src/org/apache/xindice/util FileCache.java ObjectQueue.java MD5.java Configuration.java ByteBuffer.java StringUtilities.java ByteArrayInput.java LockManager.java DirectoryClassLoader.java java/src/org/apache/xindice/core/filer SizeableMemFiler.java Paged.java FSFiler.java BTree.java java/src/org/apache/xindice/xml/jaxp DocumentBuilderImpl.java java/src/org/apache/xindice/core/meta TimeRecord.java MetaData.java java/src/org/apache/xindice/core/xupdate XUpdateImpl.java XObjectImpl.java java/src/org/apache/xindice/tools/command AddIndexer.java java/src/org/apache/xindice/xml/sax SAXEventGenerator.java java/src/org/apache/xindice/core/request URIMapper.java java/src/org/apache/xindice/core/data Value.java Types.java java/src/org/apache/xindice/tools ArgTokenizer.java java/src/org/apache/xindice/core/query NodeListSet.java QueryEngine.java XPathQueryResolver.java java/src/org/apache/xindice/core/indexer ValueIndexer.java IndexManager.java java/src/org/apache/xindice Stopwatch.java java/src/org/apache/xindice/server UglyBrowser.java java/src/org/apache/xindice/xml/dom/traversal TreeWalkerImpl.java Log: I can also commit a huge patch... these are just some braces :-) Revision Changes Path 1.9 +6 -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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MetaSystemCollection.java 8 Aug 2003 22:53:30 -0000 1.8 +++ MetaSystemCollection.java 9 Aug 2003 05:01:55 -0000 1.9 @@ -210,11 +210,13 @@ if (null != mcol) { MetaData meta = (MetaData) mcol.getObject(COLLECTION_META_DATA); - if (meta == null) + if (meta == null) { meta = new MetaData(); + } - if (meta.getType() == MetaData.UNKNOWN) + if (meta.getType() == MetaData.UNKNOWN) { meta.setType(MetaData.COLLECTION); + } meta.setOwner(collection.getCanonicalName()); meta.setDirty(false); return meta; 1.14 +5 -4 xml-xindice/java/src/org/apache/xindice/core/FaultCodes.java Index: FaultCodes.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/FaultCodes.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- FaultCodes.java 7 Aug 2003 20:13:21 -0000 1.13 +++ FaultCodes.java 9 Aug 2003 05:01:55 -0000 1.14 @@ -311,10 +311,11 @@ * @return The Fault Code */ public static int getFaultCode(Exception e) { - if (e instanceof DBException) + if (e instanceof DBException) { return ((DBException) e).faultCode; - else + } else { return 0; + } } /** 1.8 +10 -7 xml-xindice/java/src/org/apache/xindice/core/DocumentCache.java Index: DocumentCache.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/DocumentCache.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DocumentCache.java 7 Aug 2003 20:13:21 -0000 1.7 +++ DocumentCache.java 9 Aug 2003 05:01:55 -0000 1.8 @@ -89,8 +89,9 @@ public Document getDocument(Collection col, Key key) { Object v = table.get(new CacheKey(col, key)); Document doc = null; - if (v instanceof Document) + if (v instanceof Document) { doc = (Document) v; + } else if (v instanceof byte[]) { try { SymbolTable s = col.getSymbols(); @@ -147,14 +148,16 @@ } if (cache != null) { - if (cache.equals(DBDocument.CACHE)) + if (cache.equals(DBDocument.CACHE)) { return -1; - else if (cache.equals(DBDocument.NOCACHE)) + } else if (cache.equals(DBDocument.NOCACHE)) { return 0; - else + } else { return Integer.parseInt(cache); - } else + } + } else { return -1; + } } /** 1.31 +5 -4 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.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- Collection.java 9 Aug 2003 03:24:31 -0000 1.30 +++ Collection.java 9 Aug 2003 05:01:55 -0000 1.31 @@ -1283,10 +1283,11 @@ public final NodeSet queryDocument(String style, String query, NamespaceMap nsMap, Object key) throws DBException { checkFiler(FaultCodes.QRY_STYLE_NOT_FOUND); Key[] k = null; - if (key instanceof Key[]) + if (key instanceof Key[]) { k = (Key[]) key; - else + } else { k = new Key[]{createNewKey(key)}; + } return getQueryEngine().query(this, style, query, nsMap, k); } 1.7 +8 -6 xml-xindice/java/src/org/apache/xindice/xml/SymbolTable.java Index: SymbolTable.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/SymbolTable.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SymbolTable.java 8 Aug 2003 13:29:57 -0000 1.6 +++ SymbolTable.java 9 Aug 2003 05:01:55 -0000 1.7 @@ -184,9 +184,9 @@ public final short getSymbol(String qname, boolean create) { SymbolInfo info = (SymbolInfo) symbols.get(qname); - if (info != null) + if (info != null) { return info.symbol; - else if (create) { + } else if (create) { synchronized (symbols) { short id = ++maxSymbol; info = new SymbolInfo(qname, id); @@ -235,8 +235,9 @@ SymbolInfo info = (SymbolInfo) list.next(); Element e = doc.createElement(SYMBOL); e.setAttribute(NAME, info.qname); - if (info.namespaceURI != null && info.namespaceURI.length() > 0) + if (info.namespaceURI != null && info.namespaceURI.length() > 0) { e.setAttribute(NSURI, info.namespaceURI); + } e.setAttribute(ID, Short.toString(info.symbol)); root.appendChild(e); } @@ -259,8 +260,9 @@ namespaceURI = null; Short id = new Short(elem.getAttribute(ID)); - if (id.shortValue() > maxSymbol) + if (id.shortValue() > maxSymbol) { maxSymbol = id.shortValue(); + } SymbolInfo info = new SymbolInfo(qname, namespaceURI, id.shortValue()); if (namespaceURI != null) { 1.6 +4 -3 xml-xindice/java/src/org/apache/xindice/xml/NamespaceMap.java Index: NamespaceMap.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/NamespaceMap.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- NamespaceMap.java 7 Aug 2003 20:13:25 -0000 1.5 +++ NamespaceMap.java 9 Aug 2003 05:01:55 -0000 1.6 @@ -132,8 +132,9 @@ Iterator newEntries = nsMap.entrySet().iterator(); while (newEntries.hasNext()) { Map.Entry entry = (Map.Entry) newEntries.next(); - if (!override && super.containsKey(entry.getKey())) + if (!override && super.containsKey(entry.getKey())) { continue; + } super.put(entry.getKey(), entry.getValue()); } elem = null; 1.5 +4 -3 xml-xindice/java/src/org/apache/xindice/xml/XMLCompressedInput.java Index: XMLCompressedInput.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/XMLCompressedInput.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- XMLCompressedInput.java 7 Aug 2003 20:13:25 -0000 1.4 +++ XMLCompressedInput.java 9 Aug 2003 05:01:55 -0000 1.5 @@ -207,8 +207,9 @@ */ public final int readAttributeCount() throws IOException { int countType = 0; - if (getNodeType() == Node.ELEMENT_NODE) + if (getNodeType() == Node.ELEMENT_NODE) { countType = (byte) (signature & 0x03); + } switch (countType) { 1.11 +8 -5 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- TextWriter.java 7 Aug 2003 20:13:25 -0000 1.10 +++ TextWriter.java 9 Aug 2003 05:01:55 -0000 1.11 @@ -243,8 +243,9 @@ private static void writeChildren(Writer writer, Node node) throws IOException { NodeList l = node.getChildNodes(); int size = l.getLength(); - for (int i = 0; i < size; i++) + for (int i = 0; i < size; i++) { writeNode(writer, l.item(i)); + } } private static void writeEscapedText(Writer writer, String text) throws IOException { @@ -275,16 +276,18 @@ } if (outval != null) { - if (len > 0) + if (len > 0) { writer.write(value, start, len); + } writer.write(outval); start = i + 1; len = 0; outval = null; } } - if (len > 0) + if (len > 0) { writer.write(value, start, len); + } } /** 1.10 +32 -20 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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ContainerNodeImpl.java 7 Aug 2003 20:13:25 -0000 1.9 +++ ContainerNodeImpl.java 9 Aug 2003 05:01:55 -0000 1.10 @@ -120,11 +120,12 @@ } protected void checkLoaded() { - if (loaded) + if (loaded) { return; - else + } else { loaded = true; - + } + try { if (data != null) { DocumentImpl doc = (DocumentImpl) getOwnerDocument(); @@ -223,10 +224,11 @@ */ public final Node getFirstChild() { checkLoaded(); - if (childNodes.size() > 0) + if (childNodes.size() > 0) { return childNodes.item(0); - else + } else { return null; + } } /** @@ -235,10 +237,11 @@ */ public final Node getLastChild() { checkLoaded(); - if (childNodes.size() > 0) + if (childNodes.size() > 0) { return childNodes.item(childNodes.getLength() - 1); - else + } else { return null; + } } /** @@ -261,8 +264,9 @@ public final synchronized Node replaceChild(Node newChild, Node oldChild) throws DOMException { checkLoaded(); checkReadOnly(); - if (!isNodeTypeValid(newChild.getNodeType())) + if (!isNodeTypeValid(newChild.getNodeType())) { throw EX_HIERARCHY_REQUEST; + } int idx = childNodes.indexOf(oldChild); if (idx >= 0) { if (newChild.getNodeType() == DOCUMENT_FRAGMENT_NODE) { @@ -310,8 +314,9 @@ checkReadOnly(); int idx = childNodes.indexOf(refChild); if (idx >= 0) { - if (!isNodeTypeValid(newChild.getNodeType())) + if (!isNodeTypeValid(newChild.getNodeType())) { throw EX_HIERARCHY_REQUEST; + } if (newChild.getNodeType() == DOCUMENT_FRAGMENT_NODE) { NodeList nl = ((DocumentFragment) newChild).getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { @@ -342,8 +347,9 @@ public final synchronized Node removeChild(Node oldChild) throws DOMException { checkLoaded(); checkReadOnly(); - if (!childNodes.remove(oldChild)) + if (!childNodes.remove(oldChild)) { throw EX_NOT_FOUND; + } setDirty(); return oldChild; } @@ -367,8 +373,9 @@ public final synchronized Node appendChild(Node newChild) throws DOMException { checkLoaded(); checkReadOnly(); - if (!isNodeTypeValid(newChild.getNodeType())) + if (!isNodeTypeValid(newChild.getNodeType())) { throw EX_HIERARCHY_REQUEST; + } if (newChild.getNodeType() == DOCUMENT_FRAGMENT_NODE) { NodeList nl = ((DocumentFragment) newChild).getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { @@ -436,8 +443,9 @@ newList.add(s); set.clear(); } - if (add != null) + if (add != null) { newList.add(add); + } } if (modified) { @@ -460,10 +468,11 @@ NodeFilter filter = new NodeFilter() { public short acceptNode(Node node) { - if (node.getNodeName().equals(name)) + if (node.getNodeName().equals(name)) { return (short) NodeFilter.FILTER_ACCEPT; - else + } else { return (short) NodeFilter.FILTER_SKIP; + } } }; @@ -471,8 +480,9 @@ Node node = null; do { node = enum.nextNode(); - if (node != null) + if (node != null) { list.add(node); + } } while (node != null); return list; } @@ -483,10 +493,11 @@ NodeFilter filter = new NodeFilter() { public short acceptNode(Node node) { - if (node.getLocalName().equals(localName) && node.getNamespaceURI().equals(namespaceURI)) + if (node.getLocalName().equals(localName) && node.getNamespaceURI().equals(namespaceURI)) { return (short) NodeFilter.FILTER_ACCEPT; - else + } else { return (short) NodeFilter.FILTER_SKIP; + } } }; @@ -494,8 +505,9 @@ Node node = null; do { node = enum.nextNode(); - if (node != null) + if (node != null) { list.add(node); + } } while (node != null); return list; } 1.7 +25 -17 xml-xindice/java/src/org/apache/xindice/xml/dom/DOMCompressor.java Index: DOMCompressor.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/DOMCompressor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DOMCompressor.java 7 Aug 2003 20:13:25 -0000 1.6 +++ DOMCompressor.java 9 Aug 2003 05:01:55 -0000 1.7 @@ -110,17 +110,21 @@ { String nsURI = node.getNamespaceURI(); short symbolID; - if (nsURI != null) + if (nsURI != null) { symbolID = st.getSymbol(node.getNodeName(), nsURI, true); - else + } else { symbolID = st.getSymbol(node.getNodeName(), true); + } + byte signature = (byte) (Signatures.Elem << 0x6); int attrLen = node.getAttributes().getLength(); int attrSize = getSizeType(attrLen); - if (attrLen > 0) + if (attrLen > 0) { signature |= (byte) (Signatures.True << 0x5); - if (node.hasChildNodes()) + } + if (node.hasChildNodes()) { signature |= (byte) (Signatures.True << 0x4); + } signature |= (byte) (attrSize); byte[] children = buildChildren(node); int valLen = children.length; @@ -140,10 +144,11 @@ /* TODO why is it used for? String elem = */ attr.getOwnerElement().getNodeName(); String nsURI = attr.getNamespaceURI(); short symbolID; - if (nsURI != null) + if (nsURI != null) { symbolID = st.getSymbol(attr.getName(), nsURI, true); - else + } else { symbolID = st.getSymbol(attr.getName(), true); + } writeShort(symbolID); byte[] b = attr.getValue().getBytes("UTF-8"); @@ -186,17 +191,17 @@ signature |= (byte) (Signatures.CharEntity << 0x4); short symbol = 0; int encoding = 0; - if (value.equals("&")) + if (value.equals("&")) { signature |= (byte) (Signatures.EntAmp); - else if (value.equals("<")) + } else if (value.equals("<")) { signature |= (byte) (Signatures.EntLt); - else if (value.equals(">")) + } else if (value.equals(">")) { signature |= (byte) (Signatures.EntGt); - else if (value.equals(""")) + } else if (value.equals(""")) { signature |= (byte) (Signatures.EntQuot); - else if (value.equals("'")) + } else if (value.equals("'")) { signature |= (byte) (Signatures.EntApos); - else if (value.startsWith("&#x")) { + } else if (value.startsWith("&#x")) { encoding = 1; signature |= (byte) (Signatures.EntUnicode); // Convert the Unicode to a short @@ -206,8 +211,9 @@ signature |= (byte) (Signatures.EntDefined); } writeByte(signature); - if (encoding > 0) + if (encoding > 0) { writeShort(symbol); + } break; } @@ -299,13 +305,15 @@ int len = attrs.getLength(); int sizeType = getSizeType(len); out.writeSize(sizeType, len); - for (int i = 0; i < len; i++) + for (int i = 0; i < len; i++) { out.writeNode(attrs.item(i)); + } } NodeList children = node.getChildNodes(); int len = children.getLength(); - for (int i = 0; i < len; i++) + for (int i = 0; i < len; i++) { out.writeNode(children.item(i)); + } out.flush(); return bos.toByteArray(); } 1.9 +55 -29 xml-xindice/java/src/org/apache/xindice/xml/dom/NodeImpl.java Index: NodeImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/NodeImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- NodeImpl.java 7 Aug 2003 20:13:25 -0000 1.8 +++ NodeImpl.java 9 Aug 2003 05:01:55 -0000 1.9 @@ -156,8 +156,9 @@ public NodeImpl(NodeImpl parentNode, boolean dirty) { this.parentNode = parentNode; - if (dirty) + if (dirty) { setDirty(); + } } public final boolean isLoaded() { @@ -165,10 +166,11 @@ } protected void checkLoaded() { - if (loaded) + if (loaded) { return; - else + } else { loaded = true; + } } public void load() { @@ -176,8 +178,9 @@ } public void unload() { - if (loaded) + if (loaded) { loaded = false; + } } public short getSymbolID() { @@ -186,8 +189,9 @@ public final void checkReadOnly() throws DOMException { DocumentImpl doc = (DocumentImpl) getOwnerDocument(); - if (doc != null && doc.isReadOnly()) + if (doc != null && doc.isReadOnly()) { throw EX_NO_MODIFICATION_ALLOWED; + } } public final boolean isDefined() { @@ -200,8 +204,9 @@ public final void setDirty() { dirty = true; - if (parentNode != null) + if (parentNode != null) { parentNode.setDirty(); + } } public byte[] getDataBytes() { @@ -257,10 +262,11 @@ } public final NodeSource getSource() { - if (source == null && parentNode != null) + if (source == null && parentNode != null) { return parentNode.getSource(); - else + } else { return source; + } } public void expandSource() { @@ -317,8 +323,10 @@ * node is a <code>Document</code> this is <code>null</code>. */ public final Document getOwnerDocument() { - if (getNodeType() == Node.DOCUMENT_NODE) + if (getNodeType() == Node.DOCUMENT_NODE) { return (Document) this; + } + return parentNode != null ? parentNode.getOwnerDocument() : null; } @@ -511,7 +519,7 @@ pos = 0; len = data.length; } catch (Exception e) { - // Will never happen + // TODO maybe log an error... Will never happen } } @@ -536,8 +544,9 @@ DocumentFragmentImpl df = new DocumentFragmentImpl(this); if (deep) { NodeList nl = getChildNodes(); - for (int i = 0; i < nl.getLength(); i++) + for (int i = 0; i < nl.getLength(); i++) { df.appendChild(nl.item(i).cloneNode(deep)); + } } newNode = df; break; @@ -563,8 +572,9 @@ break; } - if (newNode != null) + if (newNode != null) { return newNode; + } } checkLoaded(); @@ -669,11 +679,13 @@ return XMLNS_URI; } - if (nsURI != null) + if (nsURI != null) { return nsURI; + } - if (!(nodeType == Node.ELEMENT_NODE || nodeType == Node.ATTRIBUTE_NODE)) + if (!(nodeType == Node.ELEMENT_NODE || nodeType == Node.ATTRIBUTE_NODE)) { return null; + } String prefix = getPrefix(); return prefix != null ? lookupNamespaceURI(prefix) @@ -709,8 +721,9 @@ */ public final String getPrefix() { short nodeType = getNodeType(); - if (!(nodeType == Node.ELEMENT_NODE || nodeType == Node.ATTRIBUTE_NODE)) + if (!(nodeType == Node.ELEMENT_NODE || nodeType == Node.ATTRIBUTE_NODE)) { return null; + } checkLoaded(); int idx = nodeName.indexOf(':'); return idx != -1 ? nodeName.substring(0, idx) @@ -746,14 +759,16 @@ */ public final void setPrefix(String prefix) { short nodeType = getNodeType(); - if (!(nodeType == Node.ELEMENT_NODE || nodeType == Node.ATTRIBUTE_NODE)) + if (!(nodeType == Node.ELEMENT_NODE || nodeType == Node.ATTRIBUTE_NODE)) { return; + } checkReadOnly(); String ln = getLocalName(); - if (prefix != null) + if (prefix != null) { setNodeName(prefix + ':' + ln); - else + } else { setNodeName(ln); + } } /** @@ -765,8 +780,9 @@ */ public final String getLocalName() { short nodeType = getNodeType(); - if (!(nodeType == Node.ELEMENT_NODE || nodeType == Node.ATTRIBUTE_NODE)) + if (!(nodeType == Node.ELEMENT_NODE || nodeType == Node.ATTRIBUTE_NODE)) { return null; + } String prefix = getPrefix(); return prefix != null ? getNodeName().substring(prefix.length() + 1) : getNodeName(); @@ -779,12 +795,15 @@ * @return The URI (or null) */ public final String lookupDefaultNamespaceURI() { - if (getNodeType() != Node.ELEMENT_NODE) + if (getNodeType() != Node.ELEMENT_NODE) { return null; + } String uri = ((Element) this).getAttribute(XMLNS_PREFIX); - if (uri != null && uri.length() > 0) + if (uri != null && uri.length() > 0) { return uri; + } + return parentNode != null ? parentNode.lookupDefaultNamespaceURI() : null; } @@ -818,8 +837,9 @@ Attr attr = (Attr) map.item(i); String name = attr.getName(); if (name.startsWith(XMLNS_PREFIX + ':') - && attr.getValue().equals(namespaceURI)) + && attr.getValue().equals(namespaceURI)) { return name.substring(XMLNS_PREFIX.length() + 1); + } } } return parentNode != null ? parentNode.lookupNamespacePrefix(namespaceURI) @@ -837,10 +857,13 @@ */ public final String lookupNamespaceURI(String prefix) { String uri = null; - if (getNodeType() == Node.ELEMENT_NODE) + if (getNodeType() == Node.ELEMENT_NODE) { uri = ((Element) this).getAttribute(XMLNS_PREFIX + ':' + prefix); - if (uri != null && uri.length() > 0) + } + if (uri != null && uri.length() > 0) { return uri; + } + return parentNode != null ? parentNode.lookupNamespaceURI(prefix) : null; } @@ -880,8 +903,9 @@ * key or <code>null</code>. */ public final synchronized Object setUserData(Object data, String key) { - if (userData == null) + if (userData == null) { userData = new HashMap(); + } Object oldData = userData.get(key); userData.put(key, data); return oldData; @@ -895,8 +919,9 @@ * <code>null</code>. */ public final synchronized Object getUserData(String key) { - if (userData == null) + if (userData == null) { return null; + } return userData.get(key); } @@ -908,8 +933,9 @@ * the uniqueness of this key (Node, Document, ...)? */ public final synchronized Object getKey() { - if (key == null) + if (key == null) { key = new Object(); + } return key; } } 1.9 +8 -6 xml-xindice/java/src/org/apache/xindice/xml/dom/DOMParser.java Index: DOMParser.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/DOMParser.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DOMParser.java 7 Aug 2003 20:13:25 -0000 1.8 +++ DOMParser.java 9 Aug 2003 05:01:55 -0000 1.9 @@ -301,10 +301,11 @@ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { Element e; - if (uri != null && uri.length() > 0) + if (uri != null && uri.length() > 0) { e = doc.createElementNS(uri, qName); - else + } else { e = doc.createElement(localName); + } for (int i = 0; i < attributes.getLength(); i++) { String attrURI = attributes.getURI(i); @@ -315,10 +316,11 @@ boolean isNsDef = attrQName != null && attrQName.startsWith("xmlns") && (attrQName.length() == 5 || attrQName.charAt(5) == ':'); - if (isNsDef || (attrURI != null && attrURI.length() > 0)) + if (isNsDef || (attrURI != null && attrURI.length() > 0)) { e.setAttributeNS(attrURI, attrQName, attrValue); - else + } else { e.setAttribute(attributes.getLocalName(i), attrValue); + } } context.appendChild(e); 1.6 +4 -3 xml-xindice/java/src/org/apache/xindice/xml/dom/NamedNodeMapImpl.java Index: NamedNodeMapImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/NamedNodeMapImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- NamedNodeMapImpl.java 7 Aug 2003 20:13:25 -0000 1.5 +++ NamedNodeMapImpl.java 9 Aug 2003 05:01:55 -0000 1.6 @@ -152,8 +152,9 @@ if (ns != null && ln != null && ns.equals(namespaceURI) - && ln.equals(localName)) + && ln.equals(localName)) { return node; + } } return null; } 1.8 +5 -4 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- EntityReferenceImpl.java 7 Aug 2003 20:13:25 -0000 1.7 +++ EntityReferenceImpl.java 9 Aug 2003 05:01:55 -0000 1.8 @@ -98,10 +98,11 @@ } protected void checkLoaded() { - if (loaded) + if (loaded) { return; - else + } else { loaded = true; + } try { if (data != null) { 1.5 +11 -7 xml-xindice/java/src/org/apache/xindice/xml/dom/DOMImplementationImpl.java Index: DOMImplementationImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/DOMImplementationImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DOMImplementationImpl.java 7 Aug 2003 20:13:25 -0000 1.4 +++ DOMImplementationImpl.java 9 Aug 2003 05:01:55 -0000 1.5 @@ -89,10 +89,12 @@ } public static boolean HasFeature(String feature, String version) { - for (int i = 0; i < FEATURES.length; i++) - if (FEATURES[i][0].equals(feature) + for (int i = 0; i < FEATURES.length; i++) { + if (FEATURES[i][0].equals(feature) { && FEATURES[i][1].equals(version)) return true; + } + } return false; } @@ -166,15 +168,17 @@ Element elem = doc.createElement(qualifiedName); doc.appendChild(elem); if (namespaceURI != null) { - if (qualifiedName.indexOf(":") != -1) + if (qualifiedName.indexOf(":") != -1) { elem.setAttribute("xmlns:" + qualifiedName.substring(0, qualifiedName.indexOf(":")), namespaceURI); - else + } else { elem.setAttribute("xmlns", namespaceURI); + } } if (doctype != null) { if (doctype.getOwnerDocument() != null - || !(doctype instanceof DocumentTypeImpl)) + || !(doctype instanceof DocumentTypeImpl)) { throw NodeImpl.EX_WRONG_DOCUMENT; + } doc.setDoctype(doctype); } return doc; 1.10 +7 -5 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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- DocumentImpl.java 7 Aug 2003 20:13:25 -0000 1.9 +++ DocumentImpl.java 9 Aug 2003 05:01:55 -0000 1.10 @@ -162,14 +162,16 @@ } protected void checkLoaded() { - if (loaded) + if (loaded) { return; - else + } else { loaded = true; + } try { - if (data != null) + if (data != null) { loadChildren(symbols); + } } catch (Exception e) { log.warn(e); } 1.9 +12 -8 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- CharacterDataImpl.java 7 Aug 2003 20:13:25 -0000 1.8 +++ CharacterDataImpl.java 9 Aug 2003 05:01:55 -0000 1.9 @@ -91,16 +91,18 @@ public CharacterDataImpl(NodeImpl parentNode, String nodeValue) { super(parentNode, true); - if (nodeValue == null) + if (nodeValue == null) { nodeValue = ""; + } this.nodeValue = nodeValue; } protected final void checkLoaded() { - if (loaded) + if (loaded) { return; - else + } else { loaded = true; + } try { if (data != null) { @@ -111,10 +113,11 @@ XMLCompressedInput xci = new XMLCompressedInput(bis, st); xci.readSignature(); // Skip The Signature - if (getNodeType() == TEXT_NODE) + if (getNodeType() == TEXT_NODE) { xci.readContentSize(); - else + } else { xci.readInt(); + } byte[] buf = new byte[bis.available()]; xci.read(buf); @@ -128,8 +131,9 @@ public final void setNodeValue(String nodeValue) throws DOMException { checkLoaded(); checkReadOnly(); - if (nodeValue == null) + if (nodeValue == null) { nodeValue = ""; + } this.nodeValue = nodeValue; setDirty(); } 1.14 +6 -6 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ElementImpl.java 9 Aug 2003 03:38:55 -0000 1.13 +++ ElementImpl.java 9 Aug 2003 05:01:55 -0000 1.14 @@ -75,7 +75,6 @@ import java.io.IOException; import java.util.HashSet; -import java.util.Random; /** * ElementImpl @@ -123,11 +122,12 @@ } protected void checkLoaded() { - if (loaded) + if (loaded) { return; - else + } else { loaded = true; - + } + try { if (data != null) { DocumentImpl doc = (DocumentImpl) getOwnerDocument(); 1.4 +11 -7 xml-xindice/java/src/org/apache/xindice/xml/dom/AttrImpl.java Index: AttrImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/AttrImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AttrImpl.java 7 Aug 2003 20:13:25 -0000 1.3 +++ AttrImpl.java 9 Aug 2003 05:01:55 -0000 1.4 @@ -141,10 +141,11 @@ } protected void checkLoaded() { - if (loaded) + if (loaded) { return; - else + } else { loaded = true; + } } /** @@ -190,15 +191,18 @@ public String getNodeValue() { StringBuffer sb = new StringBuffer(); int size = childNodes.getLength(); - for (int i = 0; i < size; i++) + for (int i = 0; i < size; i++) { sb.append(childNodes.item(i).getNodeValue()); + } + return sb.toString(); } public Element getOwnerElement() { - if (parentNode.getNodeType() == Node.ELEMENT_NODE) + if (parentNode.getNodeType() == Node.ELEMENT_NODE) { return (Element) parentNode; - else + } else { return null; + } } } 1.16 +7 -5 xml-xindice/java/src/org/apache/xindice/client/xmldb/resources/XMLResourceImpl.java Index: XMLResourceImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/resources/XMLResourceImpl.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- XMLResourceImpl.java 7 Aug 2003 20:13:20 -0000 1.15 +++ XMLResourceImpl.java 9 Aug 2003 05:01:55 -0000 1.16 @@ -371,10 +371,11 @@ */ public Node getContentAsDOM() throws XMLDBException { try { - if (bytes != null) + if (bytes != null) { return new DocumentImpl(bytes, symbols, null); - else + } else { return DOMParser.toDocument(content); + } } catch (Exception e) { throw FaultCodes.createXMLDBException(e); } @@ -411,8 +412,9 @@ hasSaxNamespacesPrefixes); xr.setContentHandler(handler); - if (handler instanceof ErrorHandler) + if (handler instanceof ErrorHandler) { xr.setErrorHandler((ErrorHandler) handler); + } if (content != null) { xr.parse(new InputSource(new StringReader(content))); 1.5 +8 -4 xml-xindice/java/src/org/apache/xindice/util/FileCache.java Index: FileCache.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/FileCache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- FileCache.java 7 Aug 2003 20:13:24 -0000 1.4 +++ FileCache.java 9 Aug 2003 05:01:55 -0000 1.5 @@ -102,10 +102,14 @@ boolean reload = true; FileCacheInfo finfo = (FileCacheInfo) cache.get(file); long lastmod = file.lastModified(); - if (!file.exists()) + if (!file.exists()) { return null; - if (finfo != null) + } + + if (finfo != null) { reload = (lastmod != finfo.lastModified); + } + if (reload) { try { FileInputStream fis = new FileInputStream(file); 1.5 +10 -6 xml-xindice/java/src/org/apache/xindice/util/ObjectQueue.java Index: ObjectQueue.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/ObjectQueue.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ObjectQueue.java 7 Aug 2003 20:13:24 -0000 1.4 +++ ObjectQueue.java 9 Aug 2003 05:01:55 -0000 1.5 @@ -79,11 +79,13 @@ public synchronized void add(Object value) { size++; ObjectQueueItem q = new ObjectQueueItem(value); - if (last != null) + if (last != null) { last.next = q; + } last = q; - if (first == null) + if (first == null) { first = q; + } } public synchronized Object remove() { @@ -91,11 +93,13 @@ if (q != null) { size--; first = q.next; - if (first == null) + if (first == null) { last = null; + } return q.value; - } else + } else { return null; + } } public boolean isEmpty() { 1.7 +8 -6 xml-xindice/java/src/org/apache/xindice/util/MD5.java Index: MD5.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/MD5.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- MD5.java 7 Aug 2003 20:13:24 -0000 1.6 +++ MD5.java 9 Aug 2003 05:01:55 -0000 1.7 @@ -94,9 +94,10 @@ static String byteToHexString(byte b) { int n = b; - if (n < 0) + if (n < 0) { n = 256 + n; - + } + int d1 = n / 16; int d2 = n % 16; @@ -106,9 +107,10 @@ static String byteArrayToHexString(byte[] b) { StringBuffer result = new StringBuffer(b.length * 2); - for (int i = 0; i < b.length; ++i) + for (int i = 0; i < b.length; ++i) { result.append(byteToHexString(b[i])); - + } + return result.toString(); } } 1.13 +36 -20 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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Configuration.java 8 Aug 2003 22:48:06 -0000 1.12 +++ Configuration.java 9 Aug 2003 05:01:55 -0000 1.13 @@ -119,8 +119,9 @@ * @throws ReadOnlyException If the Configuration is Read-only */ public Element getElement() throws ReadOnlyException { - if (readOnly) + if (readOnly) { throw new ReadOnlyException(); + } return config; } @@ -159,8 +160,9 @@ */ public String getAttribute(String name, String defValue) { String value = config.getAttribute(name); - if (value == null || value.length() == 0) + if (value == null || value.length() == 0) { value = defValue; + } return value; } @@ -384,8 +386,9 @@ NamedNodeMap map = config.getAttributes(); String[] result = new String[map.getLength()]; int size = map.getLength(); - for (int i = 0; i < size; i++) + for (int i = 0; i < size; i++) { result[i] = ((Attr) map.item(i)).getName(); + } return result; } @@ -408,10 +411,11 @@ */ public String getValue(String defValue) { NodeList list = config.getChildNodes(); - if (list.getLength() == 1 && list.item(0).getNodeType() == Node.TEXT_NODE) + if (list.getLength() == 1 && list.item(0).getNodeType() == Node.TEXT_NODE) { return list.item(0).getNodeValue(); - else + } else { return defValue; + } } /** @@ -714,13 +718,16 @@ NodeList list = config.getChildNodes(); int size = list.getLength(); - for (int i = 0; i < size; i++) - if (list.item(i).getNodeType() == Node.ELEMENT_NODE && list.item(i).getNodeName().equals(name)) + for (int i = 0; i < size; i++) { + if (list.item(i).getNodeType() == Node.ELEMENT_NODE && list.item(i).getNodeName().equals(name)) { return new Configuration((Element) list.item(i), readOnly); - if (create) + } + } + if (create) { return add(name); - else + } else { return null; + } } /** @@ -756,8 +763,9 @@ * @throws ReadOnlyException if the Configuration is read-only */ public Configuration add(String name) throws ReadOnlyException { - if (readOnly) + if (readOnly) { throw new ReadOnlyException(); + } Element elem = config.getOwnerDocument().createElement(name); config.appendChild(elem); //setDirty(); @@ -773,8 +781,9 @@ * @throws ReadOnlyException if the Configuration is read-only */ public void add(Configuration newConfig) throws ReadOnlyException { - if (readOnly) + if (readOnly) { throw new ReadOnlyException(); + } Node imported = config.getOwnerDocument().importNode(newConfig.config, true); config.appendChild(imported); newConfig.config = (Element) imported; @@ -787,10 +796,14 @@ * @throws ReadOnlyException if the Configuration is read-only */ public void delete() throws ReadOnlyException { - if (readOnly) + if (readOnly) { throw new ReadOnlyException(); - if (config.getParentNode() != null) + } + + if (config.getParentNode() != null) { config.getParentNode().removeChild(config); + } + //setDirty(); } @@ -801,8 +814,9 @@ * @throws ReadOnlyException if the Configuration is read-only */ public void removeAttribute(String name) throws ReadOnlyException { - if (readOnly) + if (readOnly) { throw new ReadOnlyException(); + } config.removeAttribute(name); //setDirty(); } @@ -815,8 +829,9 @@ * @throws ReadOnlyException if the Configuration is read-only */ public void setAttribute(String name, String value) throws ReadOnlyException { - if (readOnly) + if (readOnly) { throw new ReadOnlyException(); + } config.setAttribute(name, value); //setDirty(); } @@ -916,12 +931,13 @@ * @throws ReadOnlyException if the Configuration is read-only */ public void setValue(String value) throws ReadOnlyException { - if (readOnly) + if (readOnly) { throw new ReadOnlyException(); + } NodeList list = config.getChildNodes(); - if (list.getLength() == 1 && list.item(0).getNodeType() == Node.TEXT_NODE) + if (list.getLength() == 1 && list.item(0).getNodeType() == Node.TEXT_NODE) { list.item(0).setNodeValue(value); - else { + } else { Text text = config.getOwnerDocument().createTextNode(value); config.appendChild(text); } 1.6 +50 -26 xml-xindice/java/src/org/apache/xindice/util/ByteBuffer.java Index: ByteBuffer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/ByteBuffer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ByteBuffer.java 7 Aug 2003 20:13:24 -0000 1.5 +++ ByteBuffer.java 9 Aug 2003 05:01:55 -0000 1.6 @@ -115,8 +115,9 @@ if (copy) { buffer = new byte[length]; System.arraycopy(value, 0, buffer, 0, length); - } else + } else { buffer = value; + } } public ByteBuffer(byte[] value) { @@ -134,16 +135,18 @@ } public void ensureCapacity(int size) { - if (locked) + if (locked) { return; + } checkCapacity(size); } private void checkCapacity(int size) { if (size > buffer.length) { int newsize = (buffer.length + 1) * 2; - if (size > newsize) + if (size > newsize) { newsize = size; + } byte[] old = buffer; buffer = new byte[newsize]; System.arraycopy(old, 0, buffer, 0, old.length); @@ -151,8 +154,9 @@ } public void pack() { - if (locked) + if (locked) { return; + } if (buffer.length > length) { byte[] value = new byte[length]; System.arraycopy(buffer, 0, value, 0, length); @@ -163,8 +167,9 @@ /* StringBuffer style methods */ public void append(byte[] value) { - if (locked) + if (locked) { return; + } checkCapacity(length + value.length); System.arraycopy(value, 0, buffer, length, value.length); length += value.length; @@ -202,14 +207,16 @@ } public void append(char value) { - if (locked) + if (locked) { return; + } append(new char[]{value}); } public void append(byte value) { - if (locked) + if (locked) { return; + } checkCapacity(length + 1); buffer[length++] = value; } @@ -235,10 +242,12 @@ } public void insert(byte[] value, int pos) { - if (locked) + if (locked) { return; - if (pos < 0 || pos >= length) + } + if (pos < 0 || pos >= length) { throw new IndexOutOfBoundsException(); + } checkCapacity(length + value.length); byte[] temp = new byte[length - pos]; System.arraycopy(buffer, pos, temp, 0, temp.length); @@ -248,8 +257,9 @@ } public void insert(char[] value, int pos) { - if (locked) + if (locked) { return; + } insert(new String(value), pos); } @@ -283,10 +293,12 @@ } public void insert(byte value, int pos) { - if (locked) + if (locked) { return; - if (pos < 0 || pos >= length) + } + if (pos < 0 || pos >= length) { throw new IndexOutOfBoundsException(); + } checkCapacity(length + 1); byte[] temp = new byte[length - pos]; System.arraycopy(buffer, pos, temp, 0, temp.length); @@ -316,10 +328,12 @@ } public void delete(int pos, int width) { - if (locked) + if (locked) { return; - if (pos + width > length) + } + if (pos + width > length) { width = (length - pos); + } byte[] temp = new byte[length - (pos + width)]; System.arraycopy(buffer, pos + width, temp, 0, temp.length); System.arraycopy(temp, 0, buffer, pos, temp.length); @@ -409,10 +423,12 @@ } public void setLength(int value) { - if (locked) + if (locked) { return; - if (value < 0 || value > length) + } + if (value < 0 || value > length) { throw new IndexOutOfBoundsException(); + } length = value; } @@ -423,8 +439,9 @@ } public void reset() { - if (locked) + if (locked) { return; + } length = 0; } @@ -435,16 +452,19 @@ } public void setByteAt(int index, byte value) { - if (locked) + if (locked) { return; - if (index < 0 || index >= length) + } + if (index < 0 || index >= length) { throw new IndexOutOfBoundsException(); + } buffer[index] = value; } public void reverse() { - if (locked) + if (locked) { return; + } byte b = 0; for (int i = 0; i < length / 2; i++) { b = buffer[i]; @@ -478,8 +498,9 @@ } public void readFrom(InputStream in) throws IOException { - if (locked) + if (locked) { throw new IOException("ByteBuffer Is Locked"); + } int size = in.available(); checkCapacity(length + size); in.read(buffer, length, size); @@ -487,23 +508,26 @@ } public void write(int b) throws IOException { - if (locked) + if (locked) { throw new IOException("ByteBuffer Is Locked"); + } checkCapacity(length + 1); buffer[length++] = (byte) b; } public void write(byte b[]) throws IOException { - if (locked) + if (locked) { throw new IOException("ByteBuffer Is Locked"); + } checkCapacity(length + b.length); System.arraycopy(b, 0, buffer, length, b.length); length += b.length; } public void write(byte b[], int off, int len) throws IOException { - if (locked) + if (locked) { throw new IOException("ByteBuffer Is Locked"); + } checkCapacity(length + len); System.arraycopy(b, off, buffer, length, len); length += len; 1.6 +27 -18 xml-xindice/java/src/org/apache/xindice/util/StringUtilities.java Index: StringUtilities.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/StringUtilities.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- StringUtilities.java 7 Aug 2003 20:13:24 -0000 1.5 +++ StringUtilities.java 9 Aug 2003 05:01:55 -0000 1.6 @@ -110,10 +110,13 @@ public static String leftJustify(String value, int width) { StringBuffer sb = new StringBuffer(width); sb.append(value); - for (int i = sb.length(); i < width; i++) + for (int i = sb.length(); i < width; i++) { sb.append(' '); - if (sb.length() > width) + } + + if (sb.length() > width) { sb.setLength(width); + } return sb.toString(); } @@ -128,12 +131,15 @@ public static String rightJustify(String value, int width) { StringBuffer sb = new StringBuffer(width); sb.append(value); - for (int i = sb.length(); i < width; i++) + for (int i = sb.length(); i < width; i++) { sb.insert(0, ' '); - if (sb.length() > width) + } + + if (sb.length() > width) { return sb.toString().substring(sb.length() - width); - else + } else { return sb.toString(); + } } /** @@ -195,9 +201,11 @@ */ public static int findWhiteSpace(String value, int start) { char[] chars = value.toCharArray(); - for (int i = 0; i < chars.length; i++) - if (chars[i] <= 32) + for (int i = 0; i < chars.length; i++) { + if (chars[i] <= 32) { return i; + } + } return -1; } @@ -227,24 +235,25 @@ String token; while (st.hasMoreTokens()) { token = st.nextToken(); - if (token.equals("\b")) + if (token.equals("\b")) { sb.append("\\b"); - else if (token.equals("\t")) + } else if (token.equals("\t")) { sb.append("\\t"); - if (token.equals("\n")) + } if (token.equals("\n")) { sb.append("\\n"); - else if (token.equals("\f")) + } else if (token.equals("\f")) { sb.append("\\f"); - else if (token.equals("\r")) + } else if (token.equals("\r")) { sb.append("\\r"); - else if (token.equals("\"")) + } else if (token.equals("\"")) { sb.append("\\\""); - else if (token.equals("\'")) + } else if (token.equals("\'")) { sb.append("\\\'"); - else if (token.equals("\\")) + } else if (token.equals("\\")) { sb.append("\\\\"); - else + } else { sb.append(token); + } } return sb.toString(); } 1.5 +5 -4 xml-xindice/java/src/org/apache/xindice/util/ByteArrayInput.java Index: ByteArrayInput.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/ByteArrayInput.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ByteArrayInput.java 7 Aug 2003 20:13:24 -0000 1.4 +++ ByteArrayInput.java 9 Aug 2003 05:01:55 -0000 1.5 @@ -100,10 +100,11 @@ * @throws IOException if the position is out of range */ public void setPos(int pos) throws IOException { - if (pos >= 0 && pos < buf.length) + if (pos >= 0 && pos < buf.length) { this.pos = pos; - else + } else { throw new IOException("setPos position out of bounds"); + } } /** 1.5 +8 -4 xml-xindice/java/src/org/apache/xindice/util/LockManager.java Index: LockManager.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/LockManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- LockManager.java 7 Aug 2003 20:13:24 -0000 1.4 +++ LockManager.java 9 Aug 2003 05:01:55 -0000 1.5 @@ -128,8 +128,10 @@ synchronized (this) { info = (LockInfo) locks.get(key); } - if (info == null) + if (info == null) { return; + } + synchronized (info) { info.count--; info.notify(); @@ -194,8 +196,10 @@ synchronized (this) { info = (LockInfo) locks.get(key); } - if (info == null) + if (info == null) { return; + } + synchronized (info) { info.count = 0; info.notify(); 1.5 +4 -3 xml-xindice/java/src/org/apache/xindice/util/DirectoryClassLoader.java Index: DirectoryClassLoader.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/util/DirectoryClassLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DirectoryClassLoader.java 7 Aug 2003 20:13:24 -0000 1.4 +++ DirectoryClassLoader.java 9 Aug 2003 05:01:55 -0000 1.5 @@ -118,8 +118,9 @@ } cache.put(classname, c); } - if (resolve) + if (resolve) { resolveClass(c); + } return c; } catch (Exception e) { throw new ClassNotFoundException(e.toString()); 1.4 +6 -4 xml-xindice/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java Index: SizeableMemFiler.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SizeableMemFiler.java 7 Aug 2003 20:13:21 -0000 1.3 +++ SizeableMemFiler.java 9 Aug 2003 05:01:55 -0000 1.4 @@ -121,13 +121,15 @@ } private void checkOpened() throws DBException { - if (!opened) + if (!opened) { throw new FilerException(FaultCodes.COL_COLLECTION_CLOSED, "Filer is closed"); + } } private void checkReadOnly() throws DBException { - if (readOnly) + if (readOnly) { throw new FilerException(FaultCodes.COL_COLLECTION_READ_ONLY, "Filer is read-only"); + } } public boolean create() { 1.17 +51 -26 xml-xindice/java/src/org/apache/xindice/core/filer/Paged.java Index: Paged.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/Paged.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- Paged.java 8 Aug 2003 22:40:45 -0000 1.16 +++ Paged.java 9 Aug 2003 05:01:55 -0000 1.17 @@ -424,8 +424,9 @@ // Steal a deleted page p = getPage(pageNum); fileHeader.setFirstFreePage(p.getPageHeader().nextPage); - if (fileHeader.firstFreePage == NO_PAGE) + if (fileHeader.firstFreePage == NO_PAGE) { fileHeader.setLastFreePage(NO_PAGE); + } } else { // Grow the file pageNum = fileHeader.totalCount; @@ -559,8 +560,9 @@ } } - if (error) + if (error) { throw new FilerException(FaultCodes.GEN_CRITICAL_ERROR, "Error performing flush!"); + } } @@ -614,30 +616,36 @@ public static Value[] insertArrayValue(Value[] vals, Value val, int idx) { Value[] newVals = new Value[vals.length + 1]; - if (idx > 0) + if (idx > 0) { System.arraycopy(vals, 0, newVals, 0, idx); + } newVals[idx] = val; - if (idx < vals.length) + if (idx < vals.length) { System.arraycopy(vals, idx, newVals, idx + 1, vals.length - idx); + } return newVals; } public static Value[] deleteArrayValue(Value[] vals, int idx) { Value[] newVals = new Value[vals.length - 1]; - if (idx > 0) + if (idx > 0) { System.arraycopy(vals, 0, newVals, 0, idx); - if (idx < newVals.length) + } + if (idx < newVals.length) { System.arraycopy(vals, idx + 1, newVals, idx, newVals.length - idx); + } return newVals; } public static long[] insertArrayLong(long[] vals, long val, int idx) { long[] newVals = new long[vals.length + 1]; - if (idx > 0) + if (idx > 0) { System.arraycopy(vals, 0, newVals, 0, idx); + } newVals[idx] = val; - if (idx < vals.length) + if (idx < vals.length) { System.arraycopy(vals, idx, newVals, idx + 1, vals.length - idx); + } return newVals; } @@ -652,39 +660,49 @@ public static int[] insertArrayInt(int[] vals, int val, int idx) { int[] newVals = new int[vals.length + 1]; - if (idx > 0) + if (idx > 0) { System.arraycopy(vals, 0, newVals, 0, idx); + } newVals[idx] = val; - if (idx < vals.length) + if (idx < vals.length) { System.arraycopy(vals, idx, newVals, idx + 1, vals.length - idx); + } return newVals; } public static int[] deleteArrayInt(int[] vals, int idx) { int[] newVals = new int[vals.length - 1]; - if (idx > 0) + if (idx > 0) { System.arraycopy(vals, 0, newVals, 0, idx); - if (idx < newVals.length) + } + if (idx < newVals.length) { System.arraycopy(vals, idx + 1, newVals, idx, newVals.length - idx); + } return newVals; } public static short[] insertArrayShort(short[] vals, short val, int idx) { short[] newVals = new short[vals.length + 1]; - if (idx > 0) + if (idx > 0) { System.arraycopy(vals, 0, newVals, 0, idx); + } newVals[idx] = val; - if (idx < vals.length) + if (idx < vals.length) { System.arraycopy(vals, idx, newVals, idx + 1, vals.length - idx); + } + return newVals; } public static short[] deleteArrayShort(short[] vals, int idx) { short[] newVals = new short[vals.length - 1]; - if (idx > 0) + if (idx > 0) { System.arraycopy(vals, 0, newVals, 0, idx); - if (idx < newVals.length) + } + if (idx < newVals.length) { System.arraycopy(vals, idx + 1, newVals, idx, newVals.length - idx); + } + return newVals; } @@ -724,8 +742,9 @@ } public FileHeader(boolean read) throws IOException { - if (read) + if (read) { read(); + } } public synchronized final void read() throws IOException { @@ -753,8 +772,9 @@ } public synchronized final void write() throws IOException { - if (!dirty) + if (!dirty) { return; + } RandomAccessFile raf = null; try { @@ -949,8 +969,9 @@ status = dis.readByte(); dirty = false; - if (status == UNUSED) + if (status == UNUSED) { return; + } keyLen = dis.readShort(); keyHash = dis.readInt(); @@ -1167,24 +1188,28 @@ } public synchronized Key getKey() { - if (header.keyLen > 0) + if (header.keyLen > 0) { return new Key(data, keyPos, header.keyLen); - else + } else { return null; + } } public synchronized void streamTo(OutputStream os) throws IOException { - if (header.dataLen > 0) + if (header.dataLen > 0) { os.write(data, dataPos, header.dataLen); + } } public synchronized void streamFrom(InputStream is) throws IOException { int avail = is.available(); header.dataLen = fileHeader.workSize - header.keyLen; - if (avail < header.dataLen) + if (avail < header.dataLen) { header.dataLen = avail; - if (header.dataLen > 0) + } + if (header.dataLen > 0) { is.read(data, keyPos + header.keyLen, header.dataLen); + } } public synchronized boolean isLoaded() { 1.12 +19 -11 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- FSFiler.java 7 Aug 2003 20:13:21 -0000 1.11 +++ FSFiler.java 9 Aug 2003 05:01:55 -0000 1.12 @@ -130,8 +130,9 @@ } private void checkOpened() throws DBException { - if (!opened) + if (!opened) { throw new FilerException(FaultCodes.COL_COLLECTION_CLOSED, "Filer is closed"); + } } private void checkReadOnly() throws DBException { @@ -163,10 +164,11 @@ } public boolean create() { - if (!dir.exists()) + if (!dir.exists()) { return dir.mkdirs(); - else + } else { return true; + } } public void flush() { @@ -179,8 +181,9 @@ checkOpened(); String fname = key.toString(); - if (!isExtensionValid(fname)) + if (!isExtensionValid(fname)) { return null; + } File file = new File(dir, fname); try { @@ -190,8 +193,9 @@ meta.put(Record.MODIFIED, new Long(file.lastModified())); byte[] valueData = cache.getFile(file); - if (valueData != null) + if (valueData != null) { return new Record(key, new Value(valueData), meta); + } } catch (Exception e) { log.warn(e); } finally { @@ -211,8 +215,9 @@ checkReadOnly(); String fname = key.toString(); - if (!isExtensionValid(fname)) + if (!isExtensionValid(fname)) { return false; + } File file = new File(dir, fname); try { @@ -237,8 +242,9 @@ checkReadOnly(); String fname = key.toString(); - if (!isExtensionValid(fname)) + if (!isExtensionValid(fname)) { return false; + } File file = new File(dir, fname); try { @@ -271,11 +277,13 @@ private boolean isExtensionValid(String fname) { if (extensions != null) { int idx = fname.lastIndexOf('.'); - if (idx == -1) + if (idx == -1) { return false; + } String ext = fname.substring(idx + 1); - if (!extensions.contains(ext)) + if (!extensions.contains(ext)) { return false; + } } return true; } 1.16 +85 -46 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.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- BTree.java 8 Aug 2003 22:40:45 -0000 1.15 +++ BTree.java 9 Aug 2003 05:01:55 -0000 1.16 @@ -356,10 +356,11 @@ * @return The root node */ protected final BTreeNode getRootNode(BTreeRootInfo root) { - if (root.page == rootInfo.page) + if (root.page == rootInfo.page) { return rootNode; - else + } else { return getBTreeNode(root, root.getPage(), null); + } } /** @@ -533,8 +534,9 @@ // Read in the pointers ptrs = new long[ph.getPointerCount()]; - for (int i = 0; i < ptrs.length; i++) + for (int i = 0; i < ptrs.length; i++) { ptrs[i] = is.readLong(); + } cache.put(new Long(page.getPageNum()), this); } @@ -550,8 +552,9 @@ } // Write out the pointers - for (int i = 0; i < ptrs.length; i++) + for (int i = 0; i < ptrs.length; i++) { os.writeLong(ptrs[i]); + } writeValue(page, new Value(bos.toByteArray())); @@ -573,10 +576,11 @@ loadPtr = 0; } } - if (load) + if (load) { return getBTreeNode(loadNode, loadPtr, this); - else + } else { return null; + } } public synchronized void getChildStream(int idx, Streamable stream) throws IOException { @@ -645,10 +649,11 @@ setValues(insertArrayValue(values, value, idx)); setPointers(insertArrayLong(ptrs, pointer, idx)); - if (split) + if (split) { split(); - else + } else { write(); + } } return -1; @@ -667,10 +672,11 @@ setValues(insertArrayValue(values, value, idx)); setPointers(insertArrayLong(ptrs, rightPointer, idx + 1)); - if (split) + if (split) { split(); - else + } else { write(); + } } public Value getSeparator(Value value1, Value value2) { @@ -772,10 +778,11 @@ return getChildNode(idx).findValue(value); case LEAF: - if (idx < 0) + if (idx < 0) { throw new BTreeNotFoundException("Value '" + value.toString() + "' doesn't exist"); - else + } else { return ptrs[idx]; + } default : throw new BTreeCorruptException("Invalid Page Type In findValue"); @@ -799,18 +806,22 @@ case IndexQuery.BW: case IndexQuery.IN: case IndexQuery.SW: - for (int i = 0; i < ptrs.length; i++) - if (i >= leftIdx && i <= rightIdx) + for (int i = 0; i < ptrs.length; i++) { + if (i >= leftIdx && i <= rightIdx) { getChildNode(i).query(query, callback); + } + } break; case IndexQuery.NBWX: case IndexQuery.NBW: case IndexQuery.NIN: case IndexQuery.NSW: - for (int i = 0; i < ptrs.length; i++) - if (i <= leftIdx || i >= rightIdx) + for (int i = 0; i < ptrs.length; i++) { + if (i <= leftIdx || i >= rightIdx) { getChildNode(i).query(query, callback); + } + } break; case IndexQuery.EQ: @@ -819,22 +830,27 @@ case IndexQuery.LT: case IndexQuery.LEQ: - for (int i = 0; i < ptrs.length; i++) - if (i <= leftIdx) + for (int i = 0; i < ptrs.length; i++) { + if (i <= leftIdx) { getChildNode(i).query(query, callback); + } + } break; case IndexQuery.GT: case IndexQuery.GEQ: - for (int i = 0; i < ptrs.length; i++) - if (i >= rightIdx) + for (int i = 0; i < ptrs.length; i++) { + if (i >= rightIdx) { getChildNode(i).query(query, callback); + } + } break; case IndexQuery.NEQ: default : - for (int i = 0; i < ptrs.length; i++) + for (int i = 0; i < ptrs.length; i++) { getChildNode(i).query(query, callback); + } break; } break; @@ -842,64 +858,84 @@ case LEAF: switch (query.getOperator()) { case IndexQuery.EQ: - if (leftIdx >= 0) + if (leftIdx >= 0) { callback.indexInfo(values[leftIdx], ptrs[leftIdx]); + } break; case IndexQuery.NEQ: - for (int i = 0; i < ptrs.length; i++) - if (i != leftIdx) + for (int i = 0; i < ptrs.length; i++) { + if (i != leftIdx) { callback.indexInfo(values[i], ptrs[i]); + } + } break; case IndexQuery.BWX: case IndexQuery.BW: case IndexQuery.SW: case IndexQuery.IN: - if (leftIdx < 0) + if (leftIdx < 0) { leftIdx = -(leftIdx + 1); - if (rightIdx < 0) + } + if (rightIdx < 0) { rightIdx = -(rightIdx + 1); - for (int i = 0; i < ptrs.length; i++) - if (i >= leftIdx && i <= rightIdx && query.testValue(values[i])) + } + for (int i = 0; i < ptrs.length; i++) { + if (i >= leftIdx && i <= rightIdx && query.testValue(values[i])) { callback.indexInfo(values[i], ptrs[i]); + } + } break; case IndexQuery.NBWX: case IndexQuery.NBW: case IndexQuery.NSW: - if (leftIdx < 0) + if (leftIdx < 0) { leftIdx = -(leftIdx + 1); - if (rightIdx < 0) + } + if (rightIdx < 0) { rightIdx = -(rightIdx + 1); - for (int i = 0; i < ptrs.length; i++) - if ((i <= leftIdx || i >= rightIdx) && query.testValue(values[i])) + } + for (int i = 0; i < ptrs.length; i++) { + if ((i <= leftIdx || i >= rightIdx) && query.testValue(values[i])) { callback.indexInfo(values[i], ptrs[i]); + } + } break; case IndexQuery.LT: case IndexQuery.LEQ: - if (leftIdx < 0) + if (leftIdx < 0) { leftIdx = -(leftIdx + 1); - for (int i = 0; i < ptrs.length; i++) - if (i <= leftIdx && query.testValue(values[i])) + } + for (int i = 0; i < ptrs.length; i++) { + if (i <= leftIdx && query.testValue(values[i])) { callback.indexInfo(values[i], ptrs[i]); + } + } break; case IndexQuery.GT: case IndexQuery.GEQ: - if (rightIdx < 0) + if (rightIdx < 0) { rightIdx = -(rightIdx + 1); - for (int i = 0; i < ptrs.length; i++) - if (i >= rightIdx && query.testValue(values[i])) + } + + for (int i = 0; i < ptrs.length; i++) { + if (i >= rightIdx && query.testValue(values[i])) { callback.indexInfo(values[i], ptrs[i]); + } + } break; case IndexQuery.NIN: default : - for (int i = 0; i < ptrs.length; i++) - if (query.testValue(values[i])) + for (int i = 0; i < ptrs.length; i++) { + if (query.testValue(values[i])) { callback.indexInfo(values[i], ptrs[i]); + } + } break; } break; @@ -912,13 +948,15 @@ // No Query - Just Walk The Tree switch (ph.getStatus()) { case BRANCH: - for (int i = 0; i < ptrs.length; i++) + for (int i = 0; i < ptrs.length; i++) { getChildNode(i).query(query, callback); + } break; case LEAF: - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { callback.indexInfo(values[i], ptrs[i]); + } break; default : @@ -1035,10 +1073,11 @@ /** The number of pointers stored by this page */ public synchronized final short getPointerCount() { - if (getStatus() == BRANCH) + if (getStatus() == BRANCH) { return (short) (valueCount + 1); - else + } else { return valueCount; + } } } } 1.8 +5 -4 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DocumentBuilderImpl.java 7 Aug 2003 20:13:26 -0000 1.7 +++ DocumentBuilderImpl.java 9 Aug 2003 05:01:56 -0000 1.8 @@ -119,10 +119,11 @@ } public Document parse(InputSource source) throws SAXException, IOException, IllegalArgumentException { - if (source == null) + if (source == null) { throw new IllegalArgumentException(); - else + } else { parser.parse(source); + } return parser.getDocument(); } 1.5 +6 -4 xml-xindice/java/src/org/apache/xindice/core/meta/TimeRecord.java Index: TimeRecord.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/meta/TimeRecord.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TimeRecord.java 7 Aug 2003 20:13:22 -0000 1.4 +++ TimeRecord.java 9 Aug 2003 05:01:56 -0000 1.5 @@ -122,10 +122,12 @@ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("["); - if (created > 0) + if (created > 0) { buffer.append("cr=" + (new Date(created)).toString()); - if (modified > 0) + } + if (modified > 0) { buffer.append("mod=" + (new Date(modified)).toString()); + } buffer.append("]"); return buffer.toString(); } 1.9 +41 -21 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MetaData.java 8 Aug 2003 22:48:44 -0000 1.8 +++ MetaData.java 9 Aug 2003 05:01:56 -0000 1.9 @@ -235,8 +235,9 @@ * @return String the value of attribute, or null if not found */ public Object getAttribute(final Object name) { - if (null == attrs) + if (null == attrs) { return null; + } return attrs.get(name); } @@ -261,11 +262,13 @@ public Integer getAttributeAsInteger(final Object name) { Object o = getAttribute(name); - if (null == o) + if (null == o) { return null; + } - if (o instanceof Integer) + if (o instanceof Integer) { return (Integer) o; + } if (o instanceof Number) { Number n = (Number) o; @@ -282,11 +285,13 @@ public Long getAttributeAsLong(final Object name) { Object o = getAttribute(name); - if (null == o) + if (null == o) { return null; + } - if (o instanceof Long) + if (o instanceof Long) { return (Long) o; + } if (o instanceof Number) { Number n = (Number) o; @@ -303,11 +308,13 @@ public Short getAttributeAsShort(final Object name) { Object o = getAttribute(name); - if (null == o) + if (null == o) { return null; + } - if (o instanceof Short) + if (o instanceof Short) { return (Short) o; + } if (o instanceof Number) { Number n = (Number) o; @@ -390,8 +397,9 @@ for (Enumeration e = meta.getAttributeKeys(); e.hasMoreElements();) { Object key = e.nextElement(); Object value = meta.getAttribute(key); - if (null == this.attrs) + if (null == this.attrs) { this.attrs = new Hashtable(); + } this.attrs.put(key, value); } this.custom = null; @@ -572,8 +580,9 @@ if (systemElemName.equals(elementName)) { String attrStr = element.getAttribute(A_TYPE); - if (null != attrStr) + if (null != attrStr) { this.type = parseTypeString(attrStr); + } if (this.type == LINK) { this.link = element.getAttribute(A_HREF); @@ -614,10 +623,13 @@ Element e = (Element) attrList.item(j); String attrName = e.getAttribute(A_NAME); - if (null == attrName) continue; + if (null == attrName) { + continue; + } - if (null == this.attrs) + if (null == this.attrs) { this.attrs = new Hashtable(); + } this.attrs.put(attrName, e.getAttribute(A_VALUE)); } } else if (customElemName.equals(elementName)) { @@ -671,12 +683,15 @@ * @return short The short for this string. */ public static short parseTypeString(final String str) { - if (str.equalsIgnoreCase("doc")) + if (str.equalsIgnoreCase("doc")) { return DOCUMENT; - if (str.equalsIgnoreCase("col")) + } + if (str.equalsIgnoreCase("col")) { return COLLECTION; - if (str.equalsIgnoreCase("link")) + } + if (str.equalsIgnoreCase("link")) { return LINK; + } return UNKNOWN; } @@ -762,16 +777,21 @@ buffer.append("META["); buffer.append(getTypeString(type)); - if (owner != null) + if (owner != null) { buffer.append(" owner=" + owner); - if (created > 0) + } + if (created > 0) { buffer.append(" created=" + (new Date(created)).toString()); - if (modified > 0) + } + if (modified > 0) { buffer.append(" modified=" + (new Date(modified)).toString()); - if (link != null) + } + if (link != null) { buffer.append(" link=" + link); - if (attrs != null) + } + if (attrs != null) { buffer.append(" attrs=" + attrs); + } buffer.append("]"); return buffer.toString(); } 1.10 +10 -7 xml-xindice/java/src/org/apache/xindice/core/xupdate/XUpdateImpl.java Index: XUpdateImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/xupdate/XUpdateImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- XUpdateImpl.java 7 Aug 2003 20:13:23 -0000 1.9 +++ XUpdateImpl.java 9 Aug 2003 05:01:56 -0000 1.10 @@ -100,8 +100,9 @@ * Set the namespace map to be used when resolving queries */ public void setNamespaceMap(NamespaceMap nsMap) { - if (nsMap == null) + if (nsMap == null) { return; + } if (this.nsMap == null) { this.nsMap = nsMap; @@ -175,8 +176,9 @@ if (origNode instanceof CompressedNode) { CompressedNode cn = (CompressedNode) origNode; - if (cn.isDirty()) + if (cn.isDirty()) { nodesModified++; + } } } @@ -205,11 +207,12 @@ DBNode node = (DBNode) ns.getNextNode(); Document doc = node.getOwnerDocument(); - if (doc == lastDoc) + if (doc == lastDoc) { continue; // We only have to process it once - else + } else { lastDoc = doc; - + } + NodeSource source = node.getSource(); Node contextNode = doc.getDocumentElement(); 1.8 +4 -3 xml-xindice/java/src/org/apache/xindice/core/xupdate/XObjectImpl.java Index: XObjectImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/xupdate/XObjectImpl.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- XObjectImpl.java 7 Aug 2003 20:13:23 -0000 1.7 +++ XObjectImpl.java 9 Aug 2003 05:01:56 -0000 1.8 @@ -80,8 +80,9 @@ * @exception IllegalArgumentException If the given XObject was null. */ public XObjectImpl(XObject xobj) throws IllegalArgumentException { - if (xobj == null) + if (xobj == null) { throw new IllegalArgumentException("XalanXObject(): Argument was null!"); + } _xobj = xobj; } 1.8 +5 -4 xml-xindice/java/src/org/apache/xindice/tools/command/AddIndexer.java Index: AddIndexer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddIndexer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AddIndexer.java 7 Aug 2003 20:13:24 -0000 1.7 +++ AddIndexer.java 9 Aug 2003 05:01:56 -0000 1.8 @@ -112,10 +112,11 @@ // Setup optional index attributes if (table.containsKey(XMLTools.TYPE)) { String t = (String) table.get(XMLTools.TYPE); - if (t.equalsIgnoreCase("name")) + if (t.equalsIgnoreCase("name")) { idxEle.setAttribute("class", XINDICE_NAME_INDEXER); - else + } else { idxEle.setAttribute("type", (String) table.get(XMLTools.TYPE)); + } } if (table.containsKey(XMLTools.PAGE_SIZE)) { 1.23 +8 -5 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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- SAXEventGenerator.java 7 Aug 2003 20:13:26 -0000 1.22 +++ SAXEventGenerator.java 9 Aug 2003 05:01:56 -0000 1.23 @@ -230,8 +230,9 @@ properties.put(name, value); if (name.equals(CompressionHandler.HANDLER) - && value instanceof CompressionHandler) + && value instanceof CompressionHandler) { comp = (CompressionHandler) value; + } } public void setEntityResolver(EntityResolver resolver) { @@ -373,8 +374,9 @@ pos = bis.getPos(); /* TODO why is it used for? byte signature = */ in.readSignature(); len = in.readContentSize(); - if (len == 0) + if (len == 0) { len = 1; + } int type = in.getNodeType(); @@ -459,8 +461,9 @@ } content.startDocument(); boolean result = processContainer(false, pos, len); - if (result) + if (result) { content.endDocument(); + } return result; } 1.14 +15 -8 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- URIMapper.java 7 Aug 2003 20:13:23 -0000 1.13 +++ URIMapper.java 9 Aug 2003 05:01:56 -0000 1.14 @@ -247,8 +247,9 @@ public void reclaim() { reset(); - if (pool != null) + if (pool != null) { pool.putObject(this); + } } /** @@ -293,11 +294,14 @@ int start = pos; while (pos < buf.length) { lastChar = (char) buf[pos++]; - if (delims.indexOf(lastChar) != -1) + if (delims.indexOf(lastChar) != -1) { break; + } } - if (pos == buf.length && delims.indexOf(lastChar) == -1) + if (pos == buf.length && delims.indexOf(lastChar) == -1) { pos++; + } + return pos > start ? new String(buf, start, pos - start - 1) : ""; } @@ -314,8 +318,9 @@ String temp; while (true) { name = parseName("="); - if (name.length() == 0) + if (name.length() == 0) { break; + } value = parseName("?&;"); temp = params.getProperty(name); if (temp != null) { @@ -356,12 +361,14 @@ // Database check tmp = parseName("/"); - if (tmp == null) + if (tmp == null) { return; + } db = Database.getDatabase(tmp); - if (db == null) + if (db == null) { return; + } type = APPLICATION; tmp = parseName("/(?"); 1.7 +19 -12 xml-xindice/java/src/org/apache/xindice/core/data/Value.java Index: Value.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/data/Value.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Value.java 7 Aug 2003 20:13:21 -0000 1.6 +++ Value.java 9 Aug 2003 05:01:56 -0000 1.7 @@ -173,12 +173,14 @@ } public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj instanceof Value) + } + if (obj instanceof Value) { return equals((Value) obj); - else + } else { return equals(new Value(obj.toString())); + } } public final int compareTo(Value value) { @@ -201,29 +203,34 @@ } } - if (len == dlen) + if (len == dlen) { return 0; - else + } else { return len > dlen ? stop + 1 : -(stop + 1); + } } public final int compareTo(Object obj) { - if (obj instanceof Value) + if (obj instanceof Value) { return compareTo((Value) obj); - else + } else { return compareTo(new Value(obj.toString())); + } } public final boolean startsWith(Value value) { - if (len < value.len) + if (len < value.len) { return false; + } byte[] ddata = value.data; int dpos = value.pos; - for (int i = 0; i < value.len; i++) - if (data[i + pos] != ddata[i + dpos]) + for (int i = 0; i < value.len; i++) { + if (data[i + pos] != ddata[i + dpos]) { return false; + } + } return true; } 1.6 +20 -17 xml-xindice/java/src/org/apache/xindice/core/data/Types.java Index: Types.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/data/Types.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Types.java 7 Aug 2003 20:13:21 -0000 1.5 +++ Types.java 9 Aug 2003 05:01:56 -0000 1.6 @@ -105,39 +105,42 @@ * @return The type value */ public static int typeOf(Class c) { - if (c.isArray()) + if (c.isArray()) { c = c.getComponentType(); + } - if (c == void.class) + if (c == void.class) { return VOID; + } if (c.isPrimitive()) { - if (c == Boolean.TYPE) + if (c == Boolean.TYPE) { return BOOLEAN; - else if (c == Byte.TYPE) + } else if (c == Byte.TYPE) { return BYTE; - else if (c == Character.TYPE) + } else if (c == Character.TYPE) { return CHAR; - else if (c == Short.TYPE) + } else if (c == Short.TYPE) { return SHORT; - else if (c == Integer.TYPE) + } else if (c == Integer.TYPE) { return INT; - else if (c == Long.TYPE) + } else if (c == Long.TYPE) { return LONG; - else if (c == Float.TYPE) + } else if (c == Float.TYPE) { return FLOAT; - else if (c == Double.TYPE) + } else if (c == Double.TYPE) { return DOUBLE; + } } else { - if (c == String.class) + if (c == String.class) { return STRING; - else if (c == Variant.class) + } else if (c == Variant.class) { return VARIANT; - else if (Element.class.isAssignableFrom(c)) + } else if (Element.class.isAssignableFrom(c)) { return ELEMENT; - else if (Document.class.isAssignableFrom(c)) + } else if (Document.class.isAssignableFrom(c)) { return DOCUMENT; - else if (DocumentFragment.class.isAssignableFrom(c)) + } else if (DocumentFragment.class.isAssignableFrom(c)) { return DOCUMENTFRAGMENT; } return UNKNOWN; 1.5 +9 -6 xml-xindice/java/src/org/apache/xindice/tools/ArgTokenizer.java Index: ArgTokenizer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/ArgTokenizer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ArgTokenizer.java 7 Aug 2003 20:13:24 -0000 1.4 +++ ArgTokenizer.java 9 Aug 2003 05:01:56 -0000 1.5 @@ -80,8 +80,9 @@ public ArgTokenizer(String argString) { StringTokenizer st = new StringTokenizer(argString); args = new String[st.countTokens()]; - for (int i = 0; st.hasMoreTokens(); i++) + for (int i = 0; st.hasMoreTokens(); i++) { args[i] = st.nextToken(); + } } public boolean hasMoreTokens() { @@ -94,8 +95,9 @@ sb.append(args[idx++]); while (hasMoreTokens()) { String nt = args[idx]; - if (!nt.startsWith("-")) + if (!nt.startsWith("-")) { sb.append(' ' + args[idx++]); + } else break; } @@ -105,10 +107,11 @@ } public String nextToken() { - if (hasMoreTokens()) + if (hasMoreTokens()) { return args[idx++]; - else + } else { return ""; + } } } 1.6 +4 -3 xml-xindice/java/src/org/apache/xindice/core/query/NodeListSet.java Index: NodeListSet.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/query/NodeListSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- NodeListSet.java 9 Aug 2003 02:33:30 -0000 1.5 +++ NodeListSet.java 9 Aug 2003 05:01:56 -0000 1.6 @@ -84,8 +84,9 @@ public Object getNextNode() { DBNode n = (DBNode) list.item(idx++); - if (n != null) + if (n != null) { n.expandSource(); + } return n; } } 1.8 +54 -36 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- QueryEngine.java 7 Aug 2003 20:13:22 -0000 1.7 +++ QueryEngine.java 9 Aug 2003 05:01:56 -0000 1.8 @@ -138,8 +138,9 @@ private QueryResolver getResolver(String style) throws QueryException { QueryResolver res = (QueryResolver) resolvers.get(style); - if (res == null) + if (res == null) { throw new StyleNotFoundException("No Resolver available for '" + style + "' queries"); + } return res; } @@ -189,8 +190,9 @@ */ public static Key[] getUniqueKeys(IndexMatch[] matches) { SortedSet set = new TreeSet(); - for (int i = 0; i < matches.length; i++) + for (int i = 0; i < matches.length; i++) { set.add(matches[i].getKey()); + } return (Key[]) set.toArray(EmptyKeys); } @@ -206,17 +208,19 @@ public static Key[] andKeySets(Key[][] keySets) { int[] ptrs; - if (keySets.length == 0) + if (keySets.length == 0) { return EmptyKeys; - else if (keySets.length == 1) + } else if (keySets.length == 1) { return keySets[0]; - else { + } else { ptrs = new int[keySets.length]; - for (int i = 0; i < keySets.length; i++) - if (keySets[i].length == 0) + for (int i = 0; i < keySets.length; i++) { + if (keySets[i].length == 0) { return EmptyKeys; - else + } else { ptrs[i] = 0; + } + } } SortedSet set = new TreeSet(); @@ -233,14 +237,16 @@ highs.add(new Integer(i)); } else { int c = highest.compareTo(comp); - if (c != 0) + if (c != 0) { eq = false; + } if (c < 0) { highest = comp; highs.clear(); highs.add(new Integer(i)); - } else if (c == 0) + } else if (c == 0) { highs.add(new Integer(i)); + } } } if (eq) { @@ -249,13 +255,16 @@ highest = null; } for (int i = 0; i < ptrs.length; i++) { - if (!highs.contains(new Integer(i))) + if (!highs.contains(new Integer(i))) { ptrs[i]++; - if (ptrs[i] >= keySets[i].length) + } + if (ptrs[i] >= keySets[i].length) { done = true; + } } - if (!eq) + if (!eq) { highs.clear(); + } } return (Key[]) set.toArray(EmptyKeys); @@ -271,23 +280,26 @@ * @return The ORed set of Keys in order */ public static Key[] orKeySets(Key[][] keySets) { - if (keySets.length == 0) + if (keySets.length == 0) { return EmptyKeys; - else if (keySets.length == 1) + } else if (keySets.length == 1) { return keySets[0]; - else if (keySets.length == 2) { + } else if (keySets.length == 2) { // Optimization since most ORs will be 2 sets only - if (keySets[1].length == 0) + if (keySets[1].length == 0) { return keySets[0]; - else if (keySets[0].length == 0) + } else if (keySets[0].length == 0) { return keySets[1]; + } } SortedSet set = new TreeSet(); - for (int i = 0; i < keySets.length; i++) - for (int j = 0; j < keySets[i].length; j++) + for (int i = 0; i < keySets.length; i++) { + for (int j = 0; j < keySets[i].length; j++) { set.add(keySets[i][j]); + } + } return (Key[]) set.toArray(EmptyKeys); } @@ -315,8 +327,10 @@ white = false; } } - if (white && pos > 0) + if (white && pos > 0) { pos--; + } + return new String(n, 0, pos); } @@ -329,35 +343,39 @@ */ public static String expandEntities(String value) { int idx = value.indexOf('&'); - if (idx == -1) + if (idx == -1) { return value; - + } + StringBuffer sb = new StringBuffer(value.length()); int pos = 0; while (pos < value.length()) { if (idx != -1) { - if (idx > pos) + if (idx > pos) { sb.append(value.substring(pos, idx)); - + } + int end = value.indexOf(';', idx) + 1; - if (end == 0) - // Some sort of error + if (end == 0) { + // Some sort of error return value; + } String token = value.substring(idx + 1, end - 1); - if (token.equals("apos")) + if (token.equals("apos")) { sb.append("'"); - else if (token.equals("quot")) + } else if (token.equals("quot")) { sb.append("\""); - else if (token.equals("amp")) + } else if (token.equals("amp")) { sb.append("&"); - else if (token.equals("lt")) + } else if (token.equals("lt")) { sb.append("<"); - else if (token.equals("gt")) + } else if (token.equals("gt")) { sb.append(">"); - else - // Some sort of error + } else { + // Some sort of error return value; + } pos = end; idx = value.indexOf('&', pos); 1.19 +47 -28 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.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- XPathQueryResolver.java 9 Aug 2003 02:33:30 -0000 1.18 +++ XPathQueryResolver.java 9 Aug 2003 05:01:56 -0000 1.19 @@ -225,8 +225,9 @@ } catch (Exception e) { throw new CompilationException("Error Compiling XPath Expression", e); } - if (ex == null) + if (ex == null) { throw new CompilationException("Error Compiling XPath Expression: XPath Compiler.compile returned null"); + } } public String getQueryStyle() { @@ -271,8 +272,9 @@ // Fall back to a Collection scan SortedSet set = new TreeSet(); RecordSet rs = context.getFiler().getRecordSet(); - while (rs.hasMoreRecords()) + while (rs.hasMoreRecords()) { set.add(rs.getNextKey()); + } keySet = (Key[]) set.toArray(EmptyKeys); } @@ -319,8 +321,9 @@ */ private Object evaluate(String owner, int pos) throws Exception { int op = cmp.getOp(pos); - if (op == -1) + if (op == -1) { return null; + } switch (op) { @@ -484,15 +487,17 @@ NamedKeys nkr = right instanceof NamedKeys ? (NamedKeys) right : null; if (nkl != null && nkr != null && nkl.keys != null && nkr.keys != null) { Key[][] keys = new Key[][] { nkl.keys, nkr.keys }; - if (op == OpCodes.OP_OR) + if (op == OpCodes.OP_OR) { return new NamedKeys(null, false, QueryEngine.orKeySets(keys)); - else + } else { return new NamedKeys(null, false, QueryEngine.andKeySets(keys)); + } } else if (op == OpCodes.OP_AND) { - if (nkl != null && nkl.keys != null) + if (nkl != null && nkl.keys != null) { return new NamedKeys(null, false, nkl.keys); - else if (nkr != null && nkr.keys != null) + } else if (nkr != null && nkr.keys != null) { return new NamedKeys(null, false, nkr.keys); + } } return null; } @@ -520,8 +525,9 @@ default : return null; // Won't happen } - } else + } else { return queryComparison(op, owner, left, right); + } } private strictfp Object evalMathOperation(int op, String owner, int pos) throws Exception { @@ -651,8 +657,9 @@ Object obj = evaluate(owner, rp); if (obj instanceof NamedKeys) { NamedKeys nk = (NamedKeys) obj; - if (nk.keys != null) + if (nk.keys != null) { ks.add(nk.keys); + } } rp = cmp.getNextOpPos(rp); } @@ -677,12 +684,14 @@ if (args.size() == 1) { Object o = args.get(0); if (o instanceof XObject) { - if (((XObject) o).bool()) + if (((XObject) o).bool()) { return XBoolean.S_TRUE; - else + } else { return XBoolean.S_FALSE; - } else + } + } else { return o; + } } return null; } @@ -690,8 +699,9 @@ private Object funcCeiling(List args) throws Exception { if (args.size() == 1) { Object o = args.get(0); - if (o instanceof XObject) + if (o instanceof XObject) { return new XNumber(Math.ceil(((XObject) o).num())); + } } return null; } @@ -700,8 +710,9 @@ StringBuffer sb = new StringBuffer(); for (int i = 0; i < args.size(); i++) { Object o = args.get(i); - if (o instanceof XObject) + if (o instanceof XObject) { sb.append(((XObject) o).str()); + } } return new XString(sb.toString()); } @@ -711,10 +722,11 @@ Object o = args.get(0); Object s = args.get(1); if (o instanceof XObject && s instanceof XObject) { - if (((XObject) o).str().indexOf(((XObject) s).str()) != -1) + if (((XObject) o).str().indexOf(((XObject) s).str()) != -1) { return XBoolean.S_TRUE; - else + } else { return XBoolean.S_FALSE; + } } } return null; @@ -723,8 +735,9 @@ private Object funcFloor(List args) throws Exception { if (args.size() == 1) { Object o = args.get(0); - if (o instanceof XObject) + if (o instanceof XObject) { return new XNumber(Math.floor(((XObject) o).num())); + } } return null; } @@ -744,10 +757,11 @@ if (args.size() == 1) { Object o = args.get(0); if (o instanceof XObject) { - if (((XObject) o).bool()) + if (((XObject) o).bool()) { return XBoolean.S_FALSE; - else + } else { return XBoolean.S_TRUE; + } } } return null; @@ -756,10 +770,11 @@ private Object funcNumber(List args) throws Exception { if (args.size() == 1) { Object o = args.get(0); - if (o instanceof XObject) + if (o instanceof XObject) { return new XNumber(((XObject) o).num()); - else + } else { return o; + } } return null; } @@ -767,8 +782,9 @@ private Object funcRound(List args) throws Exception { if (args.size() == 1) { Object o = args.get(0); - if (o instanceof XObject) + if (o instanceof XObject) { return new XNumber(Math.round(((XObject) o).num())); + } } return null; } @@ -779,10 +795,11 @@ Object s = args.get(1); if (o instanceof XObject && s instanceof XObject) { - if (((XObject) o).str().startsWith(((XObject) s).str())) + if (((XObject) o).str().startsWith(((XObject) s).str())) { return XBoolean.S_TRUE; - else + } else { return XBoolean.S_FALSE; + } } else if (o instanceof NamedKeys && s instanceof XObject) { NamedKeys nk = (NamedKeys) o; String ps; @@ -1097,8 +1114,9 @@ xp = new XPath(query, null, pfx, XPath.SELECT, errors); } else { pfx = pr; - if (xp == null) + if (xp == null) { xp = new XPath(query, null, pfx, XPath.SELECT, errors); + } } final XObject xobject = xp.execute(xpc, n, pfx); @@ -1128,8 +1146,9 @@ break; } - if (node != null) + if (node != null) { break; + } } } 1.11 +18 -11 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ValueIndexer.java 7 Aug 2003 20:13:21 -0000 1.10 +++ ValueIndexer.java 9 Aug 2003 05:01:56 -0000 1.11 @@ -220,8 +220,9 @@ if (type != STRING && type != TRIMMED) { value = value.trim(); - if (value.length() == 0) + if (value.length() == 0) { return EmptyValue; + } byte[] b = new byte[typeSize]; try { @@ -259,12 +260,13 @@ b[1] = (byte) ((c >>> 0) & 0xFF); break; case BOOLEAN: - if ("[true][yes][1][y][on]".indexOf("[" + value.toString().toLowerCase() + "]") != -1) + if ("[true][yes][1][y][on]".indexOf("[" + value.toString().toLowerCase() + "]") != -1) { b[0] = 1; - else if ("[false][no][0][n][off]".indexOf("[" + value.toString().toLowerCase() + "]") != -1) + } else if ("[false][no][0][n][off]".indexOf("[" + value.toString().toLowerCase() + "]") != -1) { b[0] = 0; - else + } else { return EmptyValue; + } break; } return new Value(b); @@ -273,8 +275,9 @@ } } - if (type == TRIMMED) + if (type == TRIMMED) { value = QueryEngine.normalizeString(value); + } return new Value(value); } @@ -331,8 +334,9 @@ public void remove(String value, Key key, int pos, int len, short elemID, short attrID) throws DBException { Value v = getTypedValue(value); - if (type != STRING && type != TRIMMED && v.getLength() == 0) + if (type != STRING && type != TRIMMED && v.getLength() == 0) { return; + } try { BTreeRootInfo root = findBTreeRoot(v); @@ -347,8 +351,9 @@ public void add(String value, Key key, int pos, int len, short elemID, short attrID) throws DBException { Value v = getTypedValue(value); - if (type != STRING && type != TRIMMED && v.getLength() == 0) + if (type != STRING && type != TRIMMED && v.getLength() == 0) { return; + } try { BTreeRootInfo root; @@ -378,8 +383,9 @@ // Pre-process the value-set for typing and trimming if (type != STRING) { Value[] vals = query.getValues(); - for (int i = 0; i < vals.length; i++) + for (int i = 0; i < vals.length; i++) { vals[i] = getTypedValue(vals[i].toString()); + } } // Now issue the query @@ -395,8 +401,9 @@ results.add(match); else { IndexPattern pt = new IndexPattern(symbols, match.getElement(), match.getAttribute()); - if (pt.getMatchLevel(query.getPattern()) > 0) + if (pt.getMatchLevel(query.getPattern()) > 0) { results.add(match); + } } } else { BTreeRootInfo root = new BTreeRootInfo(value, pos); 1.17 +16 -10 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.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- IndexManager.java 8 Aug 2003 22:54:04 -0000 1.16 +++ IndexManager.java 9 Aug 2003 05:01:56 -0000 1.17 @@ -211,10 +211,12 @@ // Check for duplicates String name = cfg.getAttribute(NAME); Configuration[] cfgs = config.getChildren(); - for (int i = 0; i < cfgs.length; i++) - if (cfgs[i].getAttribute(NAME).equals(name)) + for (int i = 0; i < cfgs.length; i++) { + if (cfgs[i].getAttribute(NAME).equals(name)) { throw new DuplicateIndexException("Duplicate Index '" + name + "'"); - + } + } + config.add(cfg); Class c = Class.forName(className); @@ -235,8 +237,9 @@ initialize(idx, cfg); name = idx.getName(); - if (name == null || name.trim().equals("")) + if (name == null || name.trim().equals("")) { throw new CannotCreateException("No name specified"); + } IndexPattern pattern = new IndexPattern(symbols, idx.getPattern(), null); String style = idx.getIndexStyle(); @@ -561,23 +564,26 @@ } public void endElement(String namespaceURI, String localName, String qName) { - if (info.sb != null) + if (info.sb != null) { processEntry(new IndexPattern(symbols, info.symbolID), info.sb.toString(), info.pos, info.len); + } info = (StackInfo) stack.pop(); } public void characters(char ch[], int start, int length) { String val = new String(ch).trim(); - if (info.sb == null) + if (info.sb == null) { info.sb = new StringBuffer(ch.length); - else if (info.sb.length() > 0) + } else if (info.sb.length() > 0) { info.sb.append(' '); + } info.sb.append(val); } public void symbolID(short symbolID) { - if (info != null) + if (info != null) { stack.push(info); + } info = new StackInfo(symbolID); } 1.5 +16 -10 xml-xindice/java/src/org/apache/xindice/Stopwatch.java Index: Stopwatch.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/Stopwatch.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Stopwatch.java 7 Aug 2003 20:13:20 -0000 1.4 +++ Stopwatch.java 9 Aug 2003 05:01:56 -0000 1.5 @@ -75,8 +75,9 @@ } public Stopwatch(boolean immediate) { - if (immediate) + if (immediate) { start(); + } } public Stopwatch(String label) { @@ -85,8 +86,9 @@ public Stopwatch(String label, boolean immediate) { this.label = label; - if (immediate) + if (immediate) { start(); + } } public void start() { @@ -111,25 +113,28 @@ } public long elapsed() { - if (end != 0) + if (end != 0) { return (end - begin); - else + } else { return System.currentTimeMillis() - begin; + } } public long total() { - if (end != 0) + if (end != 0) { return total; - else + } else { return (System.currentTimeMillis() - begin) + total; + } } public String toString() { long t = total(); StringBuffer sb = new StringBuffer(); - if (label != null) + if (label != null) { sb.append(label + ": "); + } long hour = t / 3600000; if (hour > 0) { @@ -149,8 +154,9 @@ t = t % 1000; } - if (t > 0) + if (t > 0) { sb.append(t + "ms"); + } return sb.toString(); } 1.6 +11 -8 xml-xindice/java/src/org/apache/xindice/server/UglyBrowser.java Index: UglyBrowser.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/server/UglyBrowser.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- UglyBrowser.java 7 Aug 2003 20:13:23 -0000 1.5 +++ UglyBrowser.java 9 Aug 2003 05:01:56 -0000 1.6 @@ -167,15 +167,17 @@ String parserPath = parser.getPath(); StringBuffer baseHref = new StringBuffer(); baseHref.append("<a href=\"" + contextPath + "?" + dbLoc); - if(parserPath.startsWith("/") || dbLoc.endsWith("/")) + if(parserPath.startsWith("/") || dbLoc.endsWith("/")) { baseHref.append(parserPath); - else + } else { baseHref.append("/" + parserPath); + } for (int i = 0; i < cols.length; i++) { result.append(baseHref); - if(!baseHref.toString().endsWith("/")) + if(!baseHref.toString().endsWith("/")) { result.append("/"); + } result.append(cols[i]); result.append("\">"); result.append(cols[i]); @@ -257,10 +259,11 @@ * Is the given character allowed inside an HTML document? */ static public boolean isLegalCharacter(char c) { - if ((c <= 0x07) || (c >= 0x80)) + if ((c <= 0x07) || (c >= 0x80)) { return false; - else + } else { return true; + } } public static class XPathPseudoParser { 1.5 +21 -13 xml-xindice/java/src/org/apache/xindice/xml/dom/traversal/TreeWalkerImpl.java Index: TreeWalkerImpl.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/traversal/TreeWalkerImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TreeWalkerImpl.java 7 Aug 2003 20:13:26 -0000 1.4 +++ TreeWalkerImpl.java 9 Aug 2003 05:01:56 -0000 1.5 @@ -87,10 +87,11 @@ this.whatToShow = whatToShow; this.filter = filter; this.expand = entityReferenceExpansion; - if (acceptNode(root)) + if (acceptNode(root)) { next = root; - else + } else { nextNode(); + } } public int getShowType(Node node) { @@ -200,8 +201,9 @@ } public void setCurrentNode(Node currentNode) throws DOMException { - if (!valid) + if (!valid) { throw NodeImpl.EX_INVALID_STATE; + } next = currentNode; } @@ -216,12 +218,13 @@ public Node parentNode() { Node node = next; while (node != null) { - if (node == root) + if (node == root) { return null; + } node = node.getParentNode(); - if (node == null) + if (node == null) { return null; - else if (acceptNode(node)) { + } else if (acceptNode(node)) { next = node; return next; } @@ -302,8 +305,9 @@ if (acceptNode(node)) { next = node; return next; - } else + } else { node = node.getNextSibling(); + } } return null; } @@ -321,16 +325,20 @@ Node node = next; while (true) { node = node.getPreviousSibling(); - if (node == null) + if (node == null) { node = node.getParentNode(); - else - while (node.hasChildNodes()) + } else { + while (node.hasChildNodes()) { node = node.getLastChild(); + } + } + if (node != null && acceptNode(node)) { next = node; return next; - } else if (node == null) + } else if (node == null) { return null; + } } }