luetzkendorf    2004/12/07 09:52:20

  Modified:    src/share/org/apache/slide/search/basic/expression
                        ComparedProperty.java
               src/share/org/apache/slide/content
                        NodeRevisionDescriptor.java
               src/share/org/apache/slide/common PropertyName.java
  Log:
  introduction of PropertyName constants
  
  Revision  Changes    Path
  1.6       +5 -6      
jakarta-slide/src/share/org/apache/slide/search/basic/expression/ComparedProperty.java
  
  Index: ComparedProperty.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/expression/ComparedProperty.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ComparedProperty.java     29 Nov 2004 18:48:46 -0000      1.5
  +++ ComparedProperty.java     7 Dec 2004 17:52:20 -0000       1.6
  @@ -42,8 +42,7 @@
       /** a list of known properties, that have a numeric type */
       private static final List NUMERIC_PROPERTIES = new ArrayList ();
       static {
  -        NUMERIC_PROPERTIES.add 
(PropertyName.getPropertyName("getcontentlength",
  -                                                  
NamespaceCache.DEFAULT_URI));
  +        NUMERIC_PROPERTIES.add (PropertyName.CONTENT_LENGTH);
       }
       
       /** the property's value <literal> */
  
  
  
  1.42      +38 -55    
jakarta-slide/src/share/org/apache/slide/content/NodeRevisionDescriptor.java
  
  Index: NodeRevisionDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionDescriptor.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- NodeRevisionDescriptor.java       6 Dec 2004 08:54:14 -0000       1.41
  +++ NodeRevisionDescriptor.java       7 Dec 2004 17:52:20 -0000       1.42
  @@ -59,39 +59,22 @@
       public static final String MODIFICATION_DATE = "modificationdate";
       public static final String MODIFICATION_USER = "modificationuser";
       
  -    private static final PropertyName CREATION_DATE_PROPERTY = 
  -        PropertyName.getPropertyName(CREATION_DATE);
  -    private static final PropertyName CREATION_USER_PROPERTY = 
  -        PropertyName.getPropertyName(CREATION_USER);
  -    private static final PropertyName MODIFICATION_DATE_PROPERTY = 
  -        PropertyName.getPropertyName(MODIFICATION_DATE);
  -    private static final PropertyName MODIFICATION_USER_PROPERTY = 
  -        PropertyName.getPropertyName(MODIFICATION_USER);
  -    
  -    
       /**
        * Last modification date.
        */
       public static final String LAST_MODIFIED = "getlastmodified";
  -    private static final PropertyName LAST_MODIFIED_PROPERTY = 
  -        PropertyName.getPropertyName(LAST_MODIFIED);
  -    
       
       /**
        * Name.
        */
       public static final String NAME = "displayname";
  -    private static final PropertyName NAME_PROPERTY = 
  -        PropertyName.getPropertyName(NAME);
  -    
       
       /**
        * Type.
        */
       public static final String RESOURCE_TYPE = "resourcetype";
       public static final String TYPE = RESOURCE_TYPE;
  -    private static final PropertyName RESOURCE_TYPE_PROPERTY = 
  -        PropertyName.getPropertyName(RESOURCE_TYPE);
  +
       
       /**
        * Source.
  @@ -657,7 +640,7 @@
        * @return String name
        */
       public String getName() {
  -        NodeProperty name = getProperty(NAME_PROPERTY);
  +        NodeProperty name = getProperty(PropertyName.DISPLAY_NAME);
           if (name == null) {
               return "";
           } else {
  @@ -672,7 +655,7 @@
        * @param name New name
        */
       public void setName(String name) {
  -        setProperty(NAME_PROPERTY, name);  // live property, but can be 
modified
  +        setProperty(PropertyName.DISPLAY_NAME, name);  // live property, but 
can be modified
       }
       
       
  @@ -682,7 +665,7 @@
        * @return String
        */
       public String getETag() {
  -        NodeProperty contentType = getProperty(ETAG);
  +        NodeProperty contentType = getProperty(PropertyName.ETAG);
           if (contentType == null) {
               return "";
           } else {
  @@ -697,7 +680,7 @@
        * @param eTag  New etag
        */
       public void setETag(String eTag) {
  -        setProperty(ETAG, eTag);  // live property, can not be modified
  +        setProperty(PropertyName.ETAG, eTag);  // live property, can not be 
modified
       }
       
       
  @@ -710,7 +693,7 @@
        * @return String
        */
       public String getOwner() {
  -        NodeProperty owner = getProperty(OWNER);
  +        NodeProperty owner = getProperty(PropertyName.OWNER);
           if (owner == null) {
               return new String();
           } else {
  @@ -725,7 +708,7 @@
        * @param owner  New owner
        */
       public void setOwner(String owner) {
  -        setProperty(OWNER, owner);  // live property, can not be modified
  +        setProperty(PropertyName.OWNER, owner);  // live property, can not 
be modified
       }
       
       /**
  @@ -734,7 +717,7 @@
        * @param owner  New owner
        */
       public void setOwner(String owner, String userpath) {
  -        setProperty(OWNER, userpath + "/" + owner);  // live property, can 
not be modified
  +        setProperty(PropertyName.OWNER, userpath + "/" + owner);  // live 
property, can not be modified
       }
       
       /**
  @@ -743,7 +726,7 @@
        * @return String
        */
       public String getSource() {
  -        NodeProperty source = getProperty(SOURCE);
  +        NodeProperty source = getProperty(PropertyName.SOURCE);
           if (source == null) {
               return "";
           } else {
  @@ -758,7 +741,7 @@
        * @param source  New source
        */
       public void setSource(String source) {
  -        setProperty(SOURCE, source);  // live property, can not be modified
  +        setProperty(PropertyName.SOURCE, source);  // live property, can not 
be modified
       }
       
       
  @@ -772,7 +755,7 @@
        * @return String
        */
       public String getResourceType() {
  -        NodeProperty resourceType = getProperty(RESOURCE_TYPE_PROPERTY);
  +        NodeProperty resourceType = getProperty(PropertyName.RESOURCE_TYPE);
           if (resourceType == null) {
               return "";
           } else {
  @@ -789,7 +772,7 @@
        * @param resourceType  New ResourceType
        */
       public void setResourceType(String resourceType) {
  -        setProperty(RESOURCE_TYPE_PROPERTY, resourceType);  // live 
property, can not be modified
  +        setProperty(PropertyName.RESOURCE_TYPE, resourceType);  // live 
property, can not be modified
       }
       
       
  @@ -801,7 +784,7 @@
        * @return String
        */
       public String getContentType() {
  -        NodeProperty contentType = getProperty(CONTENT_TYPE);
  +        NodeProperty contentType = getProperty(PropertyName.CONTENT_TYPE);
           if (contentType == null) {
               return "";
           } else {
  @@ -816,7 +799,7 @@
        * @param contentType New content type
        */
       public void setContentType(String contentType) {
  -        setProperty(CONTENT_TYPE, contentType);  // live property, can not 
be modified
  +        setProperty(PropertyName.CONTENT_TYPE, contentType);  // live 
property, can not be modified
       }
       
       
  @@ -826,7 +809,7 @@
        * @return String content language
        */
       public String getContentLanguage() {
  -        NodeProperty contentLanguage = getProperty(CONTENT_LANGUAGE);
  +        NodeProperty contentLanguage = 
getProperty(PropertyName.CONTENT_LANGUAGE);
           if (contentLanguage == null) {
               return "";
           } else {
  @@ -841,7 +824,7 @@
        * @param contentLanguage New content language
        */
       public void setContentLanguage(String contentLanguage) {
  -        setProperty(CONTENT_LANGUAGE, contentLanguage);  // live property, 
can not be modified
  +        setProperty(PropertyName.CONTENT_LANGUAGE, contentLanguage);  // 
live property, can not be modified
       }
       
       
  @@ -851,7 +834,7 @@
        * @return String creation date
        */
       public String getCreationDate() {
  -        NodeProperty creationDate = getProperty(CREATION_DATE_PROPERTY);
  +        NodeProperty creationDate = getProperty(PropertyName.CREATION_DATE);
           if (creationDate == null) {
               return null;
           } else {
  @@ -870,7 +853,7 @@
        * @return String modification date
        */
       public String getModificationDate() {
  -        NodeProperty modificationDate = 
getProperty(MODIFICATION_DATE_PROPERTY);
  +        NodeProperty modificationDate = 
getProperty(PropertyName.MODIFICATION_DATE);
           if (modificationDate == null) {
               return null;
           } else {
  @@ -889,7 +872,7 @@
        * @return String
        */
       public String getCreationUser() {
  -        NodeProperty creationUser = getProperty(CREATION_USER_PROPERTY);
  +        NodeProperty creationUser = getProperty(PropertyName.CREATION_USER);
           if (creationUser == null) {
               return "";
           } else {
  @@ -904,7 +887,7 @@
        * @return String
        */
       public String getModificationUser() {
  -        NodeProperty modificationUser = 
getProperty(MODIFICATION_USER_PROPERTY);
  +        NodeProperty modificationUser = 
getProperty(PropertyName.MODIFICATION_USER);
           if (modificationUser == null) {
               return "";
           } else {
  @@ -919,7 +902,7 @@
        * @return String creation date
        */
       public Date getCreationDateAsDate() {
  -        NodeProperty creationDate = getProperty(CREATION_DATE_PROPERTY);
  +        NodeProperty creationDate = getProperty(PropertyName.CREATION_DATE);
           if (creationDate == null)
               return null;
           if (creationDate.getValue() instanceof Date) {
  @@ -949,7 +932,7 @@
        */
       public void setCreationDate(Date creationDate) {
           // live property, can not be modified
  -        setProperty(CREATION_DATE_PROPERTY, 
creationDateFormat.format(creationDate));
  +        setProperty(PropertyName.CREATION_DATE, 
creationDateFormat.format(creationDate));
       }
        
       
  @@ -960,7 +943,7 @@
        */
       public void setModificationDate(Date modificationDate) {
           // live property, can not be modified
  -        setProperty(MODIFICATION_DATE_PROPERTY, 
  +        setProperty(PropertyName.MODIFICATION_DATE, 
                   creationDateFormat.format(modificationDate));
       }
        
  @@ -972,7 +955,7 @@
        */
       public void setModificationDate(String modificationDate) {
           // live property, can not be modified
  -        setProperty(MODIFICATION_DATE_PROPERTY, modificationDate);
  +        setProperty(PropertyName.MODIFICATION_DATE, modificationDate);
       }
        
       
  @@ -983,7 +966,7 @@
        */
       public void setCreationUser(String creationUser) {
           // live property, can not be modified
  -        setProperty(CREATION_USER_PROPERTY, creationUser);
  +        setProperty(PropertyName.CREATION_USER, creationUser);
       }
        
       
  @@ -994,7 +977,7 @@
        */
       public void setModificationUser(String modificationUser) {
           // live property, can not be modified
  -        setProperty(MODIFICATION_USER_PROPERTY, modificationUser);
  +        setProperty(PropertyName.MODIFICATION_USER, modificationUser);
       }
       
       
  @@ -1004,7 +987,7 @@
        * @param creationDate New creation date
        */
       public void setCreationDate(String creationDate) {
  -        setProperty(CREATION_DATE_PROPERTY, creationDate);  // live 
property, can not be modified
  +        setProperty(PropertyName.CREATION_DATE, creationDate);  // live 
property, can not be modified
       }
       
       
  @@ -1014,7 +997,7 @@
        * @return String last modification date
        */
       public String getLastModified() {
  -        NodeProperty lastModified = getProperty(LAST_MODIFIED_PROPERTY);
  +        NodeProperty lastModified = getProperty(PropertyName.LAST_MODIFIED);
           if (lastModified == null) {
               return null;
           } else {
  @@ -1033,7 +1016,7 @@
        * @return String creation date
        */
       public Date getLastModifiedAsDate() {
  -        NodeProperty lastModified = getProperty(LAST_MODIFIED_PROPERTY);
  +        NodeProperty lastModified = getProperty(PropertyName.LAST_MODIFIED);
           if (lastModified == null)
               return null;
           if (lastModified.getValue() instanceof Date) {
  @@ -1063,7 +1046,7 @@
        */
       public void setLastModified(Date lastModified) {
           // live property, can not be modified
  -        setProperty(LAST_MODIFIED_PROPERTY, format.format(lastModified));
  +        setProperty(PropertyName.LAST_MODIFIED, format.format(lastModified));
       }
       
       
  @@ -1073,7 +1056,7 @@
        * @param lastModified New last modified
        */
       public void setLastModified(String lastModified) {
  -        setProperty(LAST_MODIFIED_PROPERTY, lastModified);   // live 
property, can not be modified
  +        setProperty(PropertyName.LAST_MODIFIED, lastModified);   // live 
property, can not be modified
       }
       
       
  @@ -1083,7 +1066,7 @@
        * @param contentLength New content length
        */
       public void setContentLength(long contentLength) {
  -        setProperty(CONTENT_LENGTH, new Long(contentLength));  // live 
property, can not be modified
  +        setProperty(PropertyName.CONTENT_LENGTH, new Long(contentLength));  
// live property, can not be modified
       }
       
       
  @@ -1102,7 +1085,7 @@
           if (contentLengthValue == null) {
               contentLengthValue = new Long(0);
           }
  -        setProperty(CONTENT_LENGTH, contentLengthValue);  // live property, 
can not be modified
  +        setProperty(PropertyName.CONTENT_LENGTH, contentLengthValue);  // 
live property, can not be modified
       }
       
       
  @@ -1112,7 +1095,7 @@
        * @return String
        */
       public long getContentLength() {
  -        NodeProperty contentLength = getProperty(CONTENT_LENGTH);
  +        NodeProperty contentLength = 
getProperty(PropertyName.CONTENT_LENGTH);
           if (contentLength == null) {
               return -1L;
           } else {
  
  
  
  1.5       +50 -23    
jakarta-slide/src/share/org/apache/slide/common/PropertyName.java
  
  Index: PropertyName.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/PropertyName.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PropertyName.java 29 Nov 2004 18:45:41 -0000      1.4
  +++ PropertyName.java 7 Dec 2004 17:52:20 -0000       1.5
  @@ -22,11 +22,11 @@
    */
   package org.apache.slide.common;
   
  -// import list
   import java.util.HashMap;
   import java.util.Map;
   
   import org.apache.slide.content.NodeProperty;
  +import org.apache.slide.content.NodeRevisionDescriptor;
   
   /**
    * This class is a container for the name and namespace of a property.
  @@ -36,6 +36,35 @@
    **/
   public class PropertyName {
       
  +    private static Map instances = new HashMap();
  +    
  +    public static final PropertyName CONTENT_LANGUAGE = 
  +        
PropertyName.getPropertyName(NodeRevisionDescriptor.CONTENT_LANGUAGE);
  +    public static final PropertyName CONTENT_LENGTH = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.CONTENT_LENGTH);
  +    public static final PropertyName CONTENT_TYPE = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.CONTENT_TYPE);
  +    public static final PropertyName CREATION_DATE = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.CREATION_DATE);
  +    public static final PropertyName CREATION_USER = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.CREATION_USER);
  +    public static final PropertyName DISPLAY_NAME = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.NAME);
  +    public static final PropertyName ETAG = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.ETAG);
  +    public static final PropertyName LAST_MODIFIED = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.LAST_MODIFIED);
  +    public static final PropertyName MODIFICATION_DATE = 
  +        
PropertyName.getPropertyName(NodeRevisionDescriptor.MODIFICATION_DATE);
  +    public static final PropertyName MODIFICATION_USER = 
  +        
PropertyName.getPropertyName(NodeRevisionDescriptor.MODIFICATION_USER);
  +    public static final PropertyName OWNER = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.OWNER);
  +    public static final PropertyName RESOURCE_TYPE = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.RESOURCE_TYPE);
  +    public static final PropertyName SOURCE = 
  +        PropertyName.getPropertyName(NodeRevisionDescriptor.SOURCE);
  +    
       /**
        * The name of the Property.
        */
  @@ -46,6 +75,7 @@
        */
       protected String namespace = null;
       
  +    private int hashCode;
       
       /**
        * Creates a PropertyName within the [EMAIL PROTECTED] 
NodeProperty#DEFAULT_NAMESPACE
  @@ -68,11 +98,11 @@
       public PropertyName(String name, String namespace) {
           this.name = name.intern();
           this.namespace = namespace.intern();
  +
  +        hashCode = this.name.hashCode();
  +        hashCode += 13 * this.namespace.hashCode();
       }
       
  -    
  -    private static Map instances = new HashMap();
  -    
       /**
        * Factory method.
        * @param name the properties name 
  @@ -80,9 +110,6 @@
        * @return a property name object 
        */
       public static PropertyName getPropertyName(String name, String 
namespace) {
  -        if (name == null) throw new NullPointerException();
  -        if (namespace == null) throw new NullPointerException();
  -        
           Map namespaceMap = (Map)instances.get(namespace);
           if (namespaceMap == null) {
               namespaceMap = new HashMap();
  @@ -91,13 +118,18 @@
           
           PropertyName result = (PropertyName)namespaceMap.get(name);
           if (result == null) {
  -            result = new PropertyName(name.intern(), namespace.intern());
  +            result = new PropertyName(name, namespace);
               namespaceMap.put(result.getName(), result);
           }
           
           return result;
       }
       
  +    /**
  +     * Factory method. Creates a property name with the default 
<code>DAV:</code> namespace.
  +     * @param name the properties name 
  +     * @return a property name object 
  +     */   
       public static PropertyName getPropertyName(String name) {
           return getPropertyName(name, NodeProperty.DEFAULT_NAMESPACE);
       }
  @@ -150,11 +182,7 @@
        * @return     the hash code of this instance.
        */
       public int hashCode() {
  -        
  -        int hash = 0;
  -        hash = this.name.hashCode();
  -        hash += 13 * this.namespace.hashCode();
  -        return hash;
  +        return hashCode;
       }
       
       /**
  @@ -163,12 +191,11 @@
        * @return     a String representation of the PropertyName.
        */
       public String toString() {
  -        StringBuffer buffer = new StringBuffer(getNamespace());
  -        buffer.append(":");
  -        if (getName() != null) {
  -            buffer.append(getName());
  -        }
  -        return buffer.toString();
  +        return new StringBuffer()
  +            .append(this.namespace)
  +            .append(':')
  +            .append(this.name)
  +            .toString();
       }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to