Ignore:
Timestamp:
2003-05-27T15:57:37+12:00 (21 years ago)
Author:
kjdon
Message:

re-tabbed the code for java

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/Format.java

    r4293 r4366  
    5656 */
    5757public class Format {
    58     /** If this format is of a true/false type, the current state. */
    59     private boolean state = false;
    60     /** The type of this format command, either FLAG, FORMAT or PARAM. */
    61     private int type = -1;
    62     /** The feature this format command affects. */
    63     private Object feature = null;
    64     /** If this format refers to a specific part of a feature, this indicates the part. */
    65     private String part = null;
    66     /** A command string, which may include a specific HTML chunk used to format a control. */
    67     private String value = null;
    68     /** An element of the format type enumeration. A true/false option. */
    69     static final public int FLAG = 0;
    70     /** An element of the format type enumeration. A string parameter. */
    71     static final public int VALUE = 1;
    72     /** The default features as specified by the Greenstone Developers manual. */
    73     static final public String DEFAULT_FEATURES[] = {"", "DocumentArrowsBottom","DocumentButtons","DocumentContents","DocumentHeading","DocumentImages","DocumentText","DocumentUseHTML","Search"};
    74     /** The list of known feature parts. */
    75     static final public String DEFAULT_PARTS[] = {"","DateList","HList","Invisible","VList"};
    76     /** Constructor for a flag format command.
    77     * @param feature The <Strong>Object</strong> this format affects.
    78     * @param part The specific part of the control to format as a <strong>String</strong>.
    79     * @param state A <i>boolean</i> indicating this formats state.
    80     */
    81     public Format(Object feature, String part, boolean state) {
    82           this.feature = feature;
    83           this.part = part;
    84           this.state = state;
    85           this.type = FLAG;
    86     }
    87     /** Constructor for a format-string format command.
    88     * @param feature The <Strong>Object</strong> this format affects.
    89     * @param part The specific part of the control to format as a <strong>String</strong>.
    90     * @param value The format <strong>String</strong> which may be a label name, or a piece of HTML formatting.
    91     */
    92     public Format(Object feature, String part, String value) {
    93           this.feature = feature;
    94           this.part = part;
    95           this.type = VALUE;
    96           this.value = value;
    97     }
    98     /** Method to retrieve the value of feature, which may either be a String or a Classifier.
    99       * @return The value of feature as an <strong>Object</strong>.
    100       */
    101     public Object getFeature() {
    102           return feature;
    103     }
    104     /** Method to retrieve the value of part.
    105       * @return The value of part as a <Strong>String</strong>.
    106       */
    107     public String getPart() {
    108           return part;
    109     }
    110     /** Method to retrieve this formats special Greenstone position code.
    111       * @return A <strong>String</strong> which distinctly indicates this classifiers position.
    112       * @see org.greenstone.gatherer.cdm.Classifier
    113       */
    114     public String getPosition() {
    115           ///ystem.err.println("Retrieving the name of feature " + feature);
    116           String position = null;
    117           if(feature instanceof Classifier) {
    118                 position = ((Classifier)feature).getPositionString();
    119           }
    120           else {
    121                 position = feature.toString();
    122           }
    123           ///ystem.err.println("Result: " + position + part);
    124           return position + part;
    125     }
    126     /** Method to retrieve the value of state.
    127       * @param The value of state as a <i>boolean</i>.
    128       */
    129     public boolean getState() {
    130           return state;
    131     }
    132     /** Method to retrieve the value of type.
    133       * @param The value of type as an <i>int</i>.
    134       */
    135     public int getType() {
    136           return type;
    137     }
    138     /** Retrieve the value of value.
    139       * @return A <strong>String</strong> which is the value of value.
    140       */
    141     public String getValue() {
    142           return value;
    143     }
    144     /** Set the value of state.
    145       * @param state The new value for state as a <i>boolean</i>.
    146       */
    147     public void setState(boolean state) {
    148           this.state = state;
    149     }
    150     /** Set the value of type.
    151       * @param type The new value for type as an <i>int</i>.
    152       */
    153     public void setType(int type) {
    154           this.type = type;
    155     }
    156     /** Set the value of value. Hmmm.
    157       * @param value The new value from value as a <strong>String</strong>.
    158       */
    159     public void setValue(String value) {
    160           this.value = value;
    161     }
    162     /** Method to translate this classes information into a line of text as you would expect in the collection configuration file.
    163       * @return A <strong>String</strong> containing the format command.
    164       */
    165     public String toString() {
    166           String text = "format ";
    167           text = text + getPosition() + " ";
    168           switch(type) {
    169           case FLAG:
    170                 if(state) {
    171                      text = text + "true";
    172                 }
    173                 else {
    174                      text = text + "false";
    175                 }
    176                 break;
    177           default:
    178                 text = text + "\"" + value + "\"";
    179           }
    180           return text;
    181     }
    182     /** Retrieve the type of a certain named feature.
    183       * @param name The name of the feature as a <strong>String</strong>.
    184       * @return An <i>int</i> indicating the type, and hence the controls needed to edit this type.
    185       */
    186     static public int getType(String name) {
    187           int index = -1;
    188           for(int i = 1; i < DEFAULT_FEATURES.length; i++) {
    189                 if(name.equalsIgnoreCase(DEFAULT_FEATURES[i])) {
    190                      index = i;
    191                 }
    192           }
    193           if(index == 1 || index == 3 || index == 5 || index == 7) {
    194                 return FLAG;
    195           }
    196           return VALUE;
    197     }
     58    /** If this format is of a true/false type, the current state. */
     59    private boolean state = false;
     60    /** The type of this format command, either FLAG, FORMAT or PARAM. */
     61    private int type = -1;
     62    /** The feature this format command affects. */
     63    private Object feature = null;
     64    /** If this format refers to a specific part of a feature, this indicates the part. */
     65    private String part = null;
     66    /** A command string, which may include a specific HTML chunk used to format a control. */
     67    private String value = null;
     68    /** An element of the format type enumeration. A true/false option. */
     69    static final public int FLAG = 0;
     70    /** An element of the format type enumeration. A string parameter. */
     71    static final public int VALUE = 1;
     72    /** The default features as specified by the Greenstone Developers manual. */
     73    static final public String DEFAULT_FEATURES[] = {"", "DocumentArrowsBottom","DocumentButtons","DocumentContents","DocumentHeading","DocumentImages","DocumentText","DocumentUseHTML","Search"};
     74    /** The list of known feature parts. */
     75    static final public String DEFAULT_PARTS[] = {"","DateList","HList","Invisible","VList"};
     76    /** Constructor for a flag format command.
     77    * @param feature The <Strong>Object</strong> this format affects.
     78    * @param part The specific part of the control to format as a <strong>String</strong>.
     79    * @param state A <i>boolean</i> indicating this formats state.
     80    */
     81    public Format(Object feature, String part, boolean state) {
     82    this.feature = feature;
     83    this.part = part;
     84    this.state = state;
     85    this.type = FLAG;
     86    }
     87    /** Constructor for a format-string format command.
     88    * @param feature The <Strong>Object</strong> this format affects.
     89    * @param part The specific part of the control to format as a <strong>String</strong>.
     90    * @param value The format <strong>String</strong> which may be a label name, or a piece of HTML formatting.
     91    */
     92    public Format(Object feature, String part, String value) {
     93    this.feature = feature;
     94    this.part = part;
     95    this.type = VALUE;
     96    this.value = value;
     97    }
     98    /** Method to retrieve the value of feature, which may either be a String or a Classifier.
     99     * @return The value of feature as an <strong>Object</strong>.
     100     */
     101    public Object getFeature() {
     102    return feature;
     103    }
     104    /** Method to retrieve the value of part.
     105     * @return The value of part as a <Strong>String</strong>.
     106     */
     107    public String getPart() {
     108    return part;
     109    }
     110    /** Method to retrieve this formats special Greenstone position code.
     111     * @return A <strong>String</strong> which distinctly indicates this classifiers position.
     112     * @see org.greenstone.gatherer.cdm.Classifier
     113     */
     114    public String getPosition() {
     115    ///ystem.err.println("Retrieving the name of feature " + feature);
     116    String position = null;
     117    if(feature instanceof Classifier) {
     118        position = ((Classifier)feature).getPositionString();
     119    }
     120    else {
     121        position = feature.toString();
     122    }
     123    ///ystem.err.println("Result: " + position + part);
     124    return position + part;
     125    }
     126    /** Method to retrieve the value of state.
     127     * @param The value of state as a <i>boolean</i>.
     128     */
     129    public boolean getState() {
     130    return state;
     131    }
     132    /** Method to retrieve the value of type.
     133     * @param The value of type as an <i>int</i>.
     134     */
     135    public int getType() {
     136    return type;
     137    }
     138    /** Retrieve the value of value.
     139     * @return A <strong>String</strong> which is the value of value.
     140     */
     141    public String getValue() {
     142    return value;
     143    }
     144    /** Set the value of state.
     145     * @param state The new value for state as a <i>boolean</i>.
     146     */
     147    public void setState(boolean state) {
     148    this.state = state;
     149    }
     150    /** Set the value of type.
     151     * @param type The new value for type as an <i>int</i>.
     152     */
     153    public void setType(int type) {
     154    this.type = type;
     155    }
     156    /** Set the value of value. Hmmm.
     157     * @param value The new value from value as a <strong>String</strong>.
     158     */
     159    public void setValue(String value) {
     160    this.value = value;
     161    }
     162    /** Method to translate this classes information into a line of text as you would expect in the collection configuration file.
     163     * @return A <strong>String</strong> containing the format command.
     164     */
     165    public String toString() {
     166    String text = "format ";
     167    text = text + getPosition() + " ";
     168    switch(type) {
     169    case FLAG:
     170        if(state) {
     171        text = text + "true";
     172        }
     173        else {
     174        text = text + "false";
     175        }
     176        break;
     177    default:
     178        text = text + "\"" + value + "\"";
     179    }
     180    return text;
     181    }
     182    /** Retrieve the type of a certain named feature.
     183     * @param name The name of the feature as a <strong>String</strong>.
     184     * @return An <i>int</i> indicating the type, and hence the controls needed to edit this type.
     185     */
     186    static public int getType(String name) {
     187    int index = -1;
     188    for(int i = 1; i < DEFAULT_FEATURES.length; i++) {
     189        if(name.equalsIgnoreCase(DEFAULT_FEATURES[i])) {
     190        index = i;
     191        }
     192    }
     193    if(index == 1 || index == 3 || index == 5 || index == 7) {
     194        return FLAG;
     195    }
     196    return VALUE;
     197    }
    198198}
Note: See TracChangeset for help on using the changeset viewer.