vgritsenko    2003/08/08 06:29:24

  Modified:    java/src/org/apache/xindice/core MetaSystemCollection.java
               java/src/org/apache/xindice/core/meta MetaData.java
  Log:
  Update according to XMLSerializable contract (remove the comment
  with doc.appendChild())
  
  Revision  Changes    Path
  1.7       +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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MetaSystemCollection.java 7 Aug 2003 20:13:21 -0000       1.6
  +++ MetaSystemCollection.java 8 Aug 2003 13:29:24 -0000       1.7
  @@ -264,11 +264,13 @@
           Collection mcol = getMetaCollection(collection, true);
           if (null != mcol) {
               MetaData meta = (MetaData) mcol.getObject(id);
  -            if (meta == null)
  +            if (meta == null) {
                   meta = new MetaData();
  +            }
   
  -            if (meta.getType() == MetaData.UNKNOWN)
  +            if (meta.getType() == MetaData.UNKNOWN) {
                   meta.setType(MetaData.DOCUMENT);
  +            }
               meta.setOwner(collection.getCanonicalName() + "/" + id);
               meta.setDirty(false);
               return meta;
  
  
  
  1.7       +36 -31    
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MetaData.java     8 Aug 2003 01:05:50 -0000       1.6
  +++ MetaData.java     8 Aug 2003 13:29:24 -0000       1.7
  @@ -243,19 +243,20 @@
   
       public Boolean getAttributeAsBoolean(final Object name) {
           Object o = getAttribute(name);
  -        if (null == o)
  +        if (null == o) {
               return null;
  +        }
   
  -        if (o instanceof Boolean)
  +        if (o instanceof Boolean) {
               return (Boolean) o;
  +        }
   
           if (o instanceof Number) {
               Number n = (Number) o;
               return new Boolean(n.intValue() != 0);
           }
   
  -        String s = o.toString();
  -        return new Boolean(s.equalsIgnoreCase("true"));
  +        return new Boolean(o.toString());
       }
   
       public Integer getAttributeAsInteger(final Object name) {
  @@ -333,8 +334,9 @@
               dirty = true;
           }
           Object prev = attrs.put(name, value);
  -        if (prev == null || !prev.equals(value))
  +        if (prev == null || !prev.equals(value)) {
               dirty = true;
  +        }
   
           return prev;
       }
  @@ -345,12 +347,14 @@
        * @return Object the removed value
        */
       public Object removeAttribute(final Object name) {
  -        if (null == attrs)
  +        if (null == attrs) {
               return null;
  +        }
   
           Object prev = attrs.remove(name);
  -        if (null != prev)
  +        if (null != prev) {
               dirty = true;
  +        }
   
           return prev;
       }
  @@ -417,8 +421,8 @@
        * Stream this MetaData into an xml document
        * @param doc the xml document to be populated.
        */
  -    public final Element streamToXML(Document doc)
  -            throws DOMException {
  +    public final Element streamToXML(Document doc) throws DOMException {
  +
           return streamToXML(doc, false);
       }
   
  @@ -439,15 +443,6 @@
               root.setAttribute("xmlns", NS_URI);
           }
   
  -        /*
  -         * Usage of streamToXML seems to be vectored through
  -         * Collection.putObject(), which adds the element returned
  -         * by streamToXML to the document.  That makes the most sense
  -         * and should be an explicit part of the XMLSerializable contract.
  -         *
  -        doc.appendChild(root);
  -         */
  -
           Element systemElement = null;
           if (!USE_NS) {
               systemElement = doc.createElement(E_SYSTEM);
  @@ -567,8 +562,9 @@
           for (int i = 0; i < list.getLength(); i++) {
               Node node = list.item(i);
   
  -            if (node.getNodeType() != Node.ELEMENT_NODE)
  +            if (node.getNodeType() != Node.ELEMENT_NODE) {
                   continue;
  +            }
   
               Element element = (Element) node;
               String elementName = element.getNodeName();
  @@ -579,15 +575,17 @@
                   if (null != attrStr)
                       this.type = parseTypeString(attrStr);
   
  -                if (this.type == LINK)
  +                if (this.type == LINK) {
                       this.link = element.getAttribute(A_HREF);
  +                }
   
                   if (includeTime) {
                       NodeList children = element.getChildNodes();
                       for (int j = 0; j < children.getLength(); j++) {
                           Node childNode = children.item(j);
  -                        if (!(childNode instanceof Element))
  +                        if (!(childNode instanceof Element)) {
                               continue;
  +                        }
   
                           Element child = (Element) childNode;
                           String childName = child.getNodeName();
  @@ -597,14 +595,16 @@
                               String nameStr = child.getAttribute(A_NAME);
                               String valueStr = child.getAttribute(A_VALUE);
                               if (null != nameStr && null != valueStr) {
  -                                if (E_CREATED.equals(nameStr))
  +                                if (E_CREATED.equals(nameStr)) {
                                       this.created = Long.parseLong(valueStr);
  -                                else if (E_MODIFIED.equals(nameStr))
  +                                } else if (E_MODIFIED.equals(nameStr)) {
                                       this.modified = Long.parseLong(valueStr);
  +                                }
                               }
                           } else {
  -                            if (log.isDebugEnabled())
  +                            if (log.isDebugEnabled()) {
                                   log.debug("Ignorning unknown child elem " + 
childName);
  +                            }
                           }
                       }
                   }
  @@ -690,22 +690,27 @@
        * @return boolean
        */
       public boolean hasContext() {
  -        if (created > 0 || modified > 0)
  +        if (created > 0 || modified > 0) {
               return true;
  -        else
  +        } else {
               return false;
  +        }
       }
   
       /**
  -     * Set the created and modified times
  +     * Set the created and modified times. If 0 value is passed,
  +     * time is not changed.
  +     *
        * @param created the new creation time
        * @param modified the new modified time
        */
       public void setContext(long created, long modified) {
  -        if (created > 0)
  +        if (created > 0) {
               this.created = created;
  -        if (modified > 0)
  +        }
  +        if (modified > 0) {
               this.modified = modified;
  +        }
       }
   
       /**
  
  
  

Reply via email to