gmazza      2004/01/04 14:04:08

  Modified:    src/java/org/apache/fop/fo PropertyList.java
  Log:
  more String->int conversions.
  
  Revision  Changes    Path
  1.16      +78 -72    xml-fop/src/java/org/apache/fop/fo/PropertyList.java
  
  Index: PropertyList.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/PropertyList.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- PropertyList.java 4 Jan 2004 21:14:34 -0000       1.15
  +++ PropertyList.java 4 Jan 2004 22:04:08 -0000       1.16
  @@ -161,6 +161,20 @@
       }
   
       /**
  +     * @return the namespace of this element
  +     */
  +    public String getNameSpace() {
  +        return namespace;
  +    }
  +
  +    /**
  +     * @return element name for this
  +     */
  +    public String getElement() {
  +        return elementName;
  +    }
  +
  +    /**
        * Return the value explicitly specified on this FO.
        * @param propertyName The name of the property whose value is desired.
        * It may be a compound name, such as space-before.optimum.
  @@ -169,6 +183,8 @@
        */
       public Property getExplicitOrShorthand(String propertyName) {
           /* Handle request for one part of a compound property */
  +        int propId = FOPropertyMapping.getPropertyId(propertyName);
  +
           int sepchar = propertyName.indexOf('.');
           String baseName;
           if (sepchar > -1) {
  @@ -181,9 +197,7 @@
               p = getShorthand(namespace, elementName, baseName);
           }
           if (p != null && sepchar > -1) {
  -            return getSubpropValue(namespace, elementName, baseName, p,
  -                                           propertyName.substring(sepchar
  -                                           + 1));
  +            return getSubpropValue(namespace, elementName, p, propId);
           }
           return p;
       }
  @@ -195,14 +209,15 @@
        * @return The value if the property is explicitly set, otherwise null.
        */
       public Property getExplicit(String propertyName) {
  +        int propId = FOPropertyMapping.getPropertyId(propertyName);
  +
           /* Handle request for one part of a compound property */
           int sepchar = propertyName.indexOf('.');
           if (sepchar > -1) {
               String baseName = propertyName.substring(0, sepchar);
               Property p = getExplicitBaseProp(baseName);
               if (p != null) {
  -                return getSubpropValue(namespace, elementName, baseName, p,
  -                    propertyName.substring(sepchar + 1));
  +                return getSubpropValue(namespace, elementName, p, propId);
               } else {
                   return null;
               }
  @@ -227,14 +242,15 @@
        * @return The inherited value, otherwise null.
        */
       public Property getInherited(String propertyName) {
  +        int propId = FOPropertyMapping.getPropertyId(propertyName);
  +
           if (parentPropertyList != null
                   && isInherited(namespace, elementName, propertyName)) {
  -            int propertyId = FOPropertyMapping.getPropertyId(propertyName);
  -            return parentPropertyList.get(propertyId);
  +            return parentPropertyList.get(propId);
           } else {
               // return the "initial" value
               try {
  -                return makeProperty(namespace, elementName, propertyName);
  +                return makeProperty(namespace, elementName, propId);
               } catch (org.apache.fop.apps.FOPException e) {
                   //log.error("Exception in getInherited(): property="
                   //                       + propertyName + " : " + e);
  @@ -243,37 +259,6 @@
           return null;    // Exception in makeProperty!
       }
   
  -    /*
  -     * If the property is a relative property with a corresponding absolute
  -     * value specified, the absolute value is used. This is also true of
  -     * the inheritance priority (I think...)
  -     * If the property is an "absolute" property and it isn't specified, then
  -     * we try to compute it from the corresponding relative property: this
  -     * happends in computeProperty.
  -     */
  -    private Property findProperty(String propertyName, boolean bTryInherit) {
  -        Property p = null;
  -        if (isCorrespondingForced(namespace, elementName, propertyName)) {
  -            p = computeProperty(namespace, elementName, propertyName);
  -        } else {
  -            p = getExplicitBaseProp(propertyName);
  -            if (p == null) {
  -                p = this.computeProperty(namespace, elementName, propertyName);
  -            }
  -            if (p == null) {    // check for shorthand specification
  -                p = getShorthand(namespace, elementName, propertyName);
  -            }
  -            if (p == null && bTryInherit) {    
  -                // else inherit (if has parent and is inheritable)
  -                if (this.parentPropertyList != null
  -                        && isInherited(namespace, elementName, propertyName)) {
  -                    p = parentPropertyList.findProperty(propertyName, true);
  -                }
  -            }
  -        }
  -        return p;
  -    }
  -
       /**
        * Return the property on the current FlowObject. If it isn't set explicitly,
        * this will try to compute it based on other properties, or if it is
  @@ -283,8 +268,7 @@
        * @return the Property corresponding to that name
        */
       public Property get(int propId) {
  -        String propertyName = FOPropertyMapping.getPropertyName(propId);
  -        return get(propertyName, true, true);
  +        return get(propId, true, true);
       }
   
       /**
  @@ -293,21 +277,15 @@
        * inheritable, to return the inherited value. If all else fails, it returns
        * the default value.
        */
  -    private Property get(String propertyName, boolean bTryInherit,
  +    private Property get(int propId, boolean bTryInherit,
                            boolean bTryDefault) {
   
  -        /* Handle request for one part of a compound property */
  -        int sepchar = propertyName.indexOf('.');
  -        String subpropName = null;
  -        if (sepchar > -1) {
  -            subpropName = propertyName.substring(sepchar + 1);
  -            propertyName = propertyName.substring(0, sepchar);
  -        }
  -
  -        Property p = findProperty(propertyName, bTryInherit);
  +        Property p = findProperty(propId & Constants.PROPERTY_MASK, 
  +                                    bTryInherit);
           if (p == null && bTryDefault) {    // default value for this FO!
               try {
  -                p = makeProperty(namespace, elementName, propertyName);
  +                p = makeProperty(namespace, elementName, 
  +                                    propId & Constants.PROPERTY_MASK);
               } catch (FOPException e) {
                   // don't know what to do here
               }
  @@ -317,30 +295,50 @@
           // parent
           if (p != null && "inherit".equals(p.getSpecifiedValue())) {
               if (this.parentPropertyList != null) {
  -                p = parentPropertyList.get(propertyName, true, false);
  +                p = parentPropertyList.get(propId, true, false);
               }
           }
   
  -        if (subpropName != null && p != null) {
  -            return getSubpropValue(namespace, elementName, propertyName, p,
  -                subpropName);
  +        if ((propId & Constants.COMPOUND_MASK) != 0 && p != null) {
  +            return getSubpropValue(namespace, elementName, p,
  +                propId);
           } else {
               return p;
           }
       }
   
  -    /**
  -     * @return the namespace of this element
  +    /*
  +     * If the property is a relative property with a corresponding absolute
  +     * value specified, the absolute value is used. This is also true of
  +     * the inheritance priority (I think...)
  +     * If the property is an "absolute" property and it isn't specified, then
  +     * we try to compute it from the corresponding relative property: this
  +     * happends in computeProperty.
        */
  -    public String getNameSpace() {
  -        return namespace;
  -    }
  +    private Property findProperty(int propId, boolean bTryInherit) {
   
  -    /**
  -     * @return element name for this
  -     */
  -    public String getElement() {
  -        return elementName;
  +        String propertyName = FOPropertyMapping.getPropertyName(propId);
  +
  +        Property p = null;
  +        if (isCorrespondingForced(namespace, elementName, propertyName)) {
  +            p = computeProperty(namespace, elementName, propertyName);
  +        } else {
  +            p = getExplicitBaseProp(propertyName);
  +            if (p == null) {
  +                p = this.computeProperty(namespace, elementName, propertyName);
  +            }
  +            if (p == null) {    // check for shorthand specification
  +                p = getShorthand(namespace, elementName, propertyName);
  +            }
  +            if (p == null && bTryInherit) {    
  +                // else inherit (if has parent and is inheritable)
  +                if (this.parentPropertyList != null
  +                        && isInherited(namespace, elementName, propertyName)) {
  +                    p = parentPropertyList.findProperty(propId, true);
  +                }
  +            }
  +        }
  +        return p;
       }
   
       /**
  @@ -351,6 +349,8 @@
        * ancestor of the current FO, else the initial value.
        */
       public Property getNearestSpecified(String propertyName) {
  +        int propId = FOPropertyMapping.getPropertyId(propertyName);
  +
           Property p = null;
           for (PropertyList plist = this; p == null && plist != null;
                   plist = plist.parentPropertyList) {
  @@ -359,7 +359,7 @@
           if (p == null) {
               // If no explicit setting found, return initial (default) value.
               try {
  -                p = makeProperty(namespace, elementName, propertyName);
  +                p = makeProperty(namespace, elementName, propId);
               } catch (FOPException e) {
                   //log.error("Exception in getNearestSpecified(): property="
                   //                       + propertyName + " : " + e);
  @@ -382,7 +382,7 @@
               return parentPropertyList.get(propId);
           } else {
               try {
  -                return makeProperty(namespace, elementName, propertyName);
  +                return makeProperty(namespace, elementName, propId);
               } catch (org.apache.fop.apps.FOPException e) {
                   //log.error("Exception in getFromParent(): property="
                   //                       + propertyName + " : " + e);
  @@ -597,8 +597,14 @@
        * @return the sub-property
        */
       public Property getSubpropValue(String space, String element,
  -                                    String propertyName, Property p,
  -                                    String subpropName) {
  +                                    Property p, int propId) {
  +
  +        String propertyName = FOPropertyMapping.getPropertyName(propId &
  +            Constants.PROPERTY_MASK);
  +                                        
  +        String subpropName = FOPropertyMapping.getPropertyName(propId &
  +            Constants.COMPOUND_MASK);
  +
           Property.Maker maker = findMaker(space, element, propertyName);
           if (maker != null) {
               return maker.getSubpropValue(p, subpropName);
  @@ -651,8 +657,9 @@
        * @throws FOPException for errors in the input
        */
       public Property makeProperty(String space, String element,
  -                                 String propertyName) throws FOPException {
  +                                 int propId) throws FOPException {
   
  +        String propertyName = FOPropertyMapping.getPropertyName(propId);
           Property p = null;
   
           Property.Maker propertyMaker = findMaker(space, element,
  @@ -668,7 +675,6 @@
   
       /**
        *
  -     * @param propertyList collection of properties
        * @param space namespace of element
        * @param element name of element
        * @param propertyName name of property
  
  
  

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

Reply via email to