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/CollectionMeta.java

    r4293 r4366  
    5959 */
    6060public class CollectionMeta
    61     implements Comparable {
    62     /** A reference to the collection design manager for access to the language manager. */
    63     private CollectionDesignManager manager = null;
    64     /** The language of this metadata. Should be a two letter code. */
    65     private Language language = null;
    66     /** The name of the thing this metadata is assigned to, which may index an Index. */
    67     private Object name = null;
    68     /** The value of this metadata. */
    69     private String value = null;
    70     /** Constructor.
    71       * @param name The object the metadata is assigned to as an <strong>Object</strong>.
    72       * @param language The language of the metadata as a <strong>Language</strong>. Should be a two letter code.
    73       * @param value The value of this metadata, as a <strong>String</strong>.
     61    implements Comparable {
     62    /** A reference to the collection design manager for access to the language manager. */
     63    private CollectionDesignManager manager = null;
     64    /** The language of this metadata. Should be a two letter code. */
     65    private Language language = null;
     66    /** The name of the thing this metadata is assigned to, which may index an Index. */
     67    private Object name = null;
     68    /** The value of this metadata. */
     69    private String value = null;
     70    /** Constructor.
     71     * @param name The object the metadata is assigned to as an <strong>Object</strong>.
     72     * @param language The language of the metadata as a <strong>Language</strong>. Should be a two letter code.
     73     * @param value The value of this metadata, as a <strong>String</strong>.
    7474      */
    75     public CollectionMeta(CollectionDesignManager manager, Object name, Language language, String value) {
    76           this.language = language;
    77           this.manager = manager;
    78           this.name = name;
    79           this.value = value;
    80     }
    81     /** Method to compare two collection metadata objects to calculate their respective ordering.
     75    public CollectionMeta(CollectionDesignManager manager, Object name, Language language, String value) {
     76    this.language = language;
     77    this.manager = manager;
     78    this.name = name;
     79    this.value = value;
     80    }
     81    /** Method to compare two collection metadata objects to calculate their respective ordering.
    8282      * @param object The other metadata to compare to, as an <strong>Object</strong>.
    8383      * @return An <i>int</i> which is less than 0 if this object proceeds the given object, 0 if they are equal and greater than 0 otherwise.
    8484      * @see org.greenstone.gatherer.cdm.Language
    8585      */
    86     public int compareTo(Object object) {
    87           if(object instanceof CollectionMeta) {
    88                 CollectionMeta metadata = (CollectionMeta) object;
    89                 int result = name.toString().compareTo(metadata.getName().toString());
    90                 if(result == 0) {
    91                      Language other_language = metadata.getLanguage();
    92                      if(language != null && other_language != null) {
    93                           result = language.compareTo(metadata.getLanguage());
    94                           if(result == 0) {
    95                                 return value.compareTo(metadata.getValue());
    96                           }
    97                      }
    98                      else if(language != null) {
    99                           return -1;
    100                      }
    101                      else if(other_language != null) {
    102                           return 1;
    103                      }
    104                 }
    105                 return result;
    106           }
    107           return toString().compareTo(object.toString());
    108     }
    109     /** Method to compare two collection metadata objects for equality.
     86    public int compareTo(Object object) {
     87    if(object instanceof CollectionMeta) {
     88        CollectionMeta metadata = (CollectionMeta) object;
     89        int result = name.toString().compareTo(metadata.getName().toString());
     90        if(result == 0) {
     91        Language other_language = metadata.getLanguage();
     92        if(language != null && other_language != null) {
     93            result = language.compareTo(metadata.getLanguage());
     94            if(result == 0) {
     95            return value.compareTo(metadata.getValue());
     96            }
     97        }
     98        else if(language != null) {
     99            return -1;
     100        }
     101        else if(other_language != null) {
     102            return 1;
     103        }
     104        }
     105        return result;
     106    }
     107    return toString().compareTo(object.toString());
     108    }
     109    /** Method to compare two collection metadata objects for equality.
    110110      * @param object The other metadata to compare to, as an <strong>Object</strong>.
    111111      * @return A <i>boolean</i> value of <i>true</i> if the object are equal, <i>false</i> otherwise.
    112112      */
    113     public boolean equals(Object object) {
    114           if(compareTo(object) == 0) {
    115                 return true;
    116           }
    117           return false;
    118     }
    119     /** Method to retrieve the value of language.
     113    public boolean equals(Object object) {
     114    if(compareTo(object) == 0) {
     115        return true;
     116    }
     117    return false;
     118    }
     119    /** Method to retrieve the value of language.
    120120      * @return The value of language as a <strong>Language</strong>.
    121121      */
    122     public Language getLanguage() {
    123           return language;
    124     }
    125     /** Method to retrieve the value of name.
     122    public Language getLanguage() {
     123    return language;
     124    }
     125    /** Method to retrieve the value of name.
    126126      * @return The value of name as an <strong>Object</strong>.
    127127      */
    128     public Object getName() {
    129           return name;
    130     }
    131     /** Method to retrieve the value of value (well great choice of name there).
     128    public Object getName() {
     129    return name;
     130    }
     131    /** Method to retrieve the value of value (well great choice of name there).
    132132      * @return The value of value as a <strong>String</strong>.
    133133      */
    134     public String getValue() {
    135           return value;
    136     }
    137     /** Method to print out this class as it would appear within the collection configuration file.
     134    public String getValue() {
     135    return value;
     136    }
     137    /** Method to print out this class as it would appear within the collection configuration file.
    138138      * @return A <strong>String</strong> containing the text value of this class.
    139139      */
    140     public String toString() {
    141           String text = "collectionmeta ";
    142           if(name instanceof Index) {
    143                 text = text + ".";
    144                 Index index = (Index)name;
    145                 text = text + index.toString(false) + " ";
    146           }
    147           else {
    148                 text = text + name.toString() + " ";
    149           }
    150           if(language != null && manager.languages.size() > 0 && !manager.languages.isDefaultLanguage(language)) {
    151                 text = text + "[l=" + language.getCode() + "] ";
    152           }
    153           text = text + "\"" + Utility.encodeGreenstone(value) + "\"\n";
    154           return text;
    155     }
    156     /** Used to update the contents of this collection level metadata to the given 'new' values.
     140    public String toString() {
     141    String text = "collectionmeta ";
     142    if(name instanceof Index) {
     143        text = text + ".";
     144        Index index = (Index)name;
     145        text = text + index.toString(false) + " ";
     146    }
     147    else {
     148        text = text + name.toString() + " ";
     149    }
     150    if(language != null && manager.languages.size() > 0 && !manager.languages.isDefaultLanguage(language)) {
     151        text = text + "[l=" + language.getCode() + "] ";
     152    }
     153    text = text + "\"" + Utility.encodeGreenstone(value) + "\"\n";
     154    return text;
     155    }
     156    /** Used to update the contents of this collection level metadata to the given 'new' values.
    157157      * @param name The new name of the metadata, as a <strong>Object</strong>.
    158158      * @param language The new <strong>Language</strong> of the metadata.
    159159      * @param value And the value the metadata is assigned, as a <strong>String</strong>.
    160160      */
    161     public void update(Object name, Language language, String value) {
    162           this.name = name;
    163           this.language = language;
    164           this.value = value;
    165     }
    166     /** Ensure this is a valid metadata entry by checking that the value is non-null and non-zero length (after having removed whitespace).
     161    public void update(Object name, Language language, String value) {
     162    this.name = name;
     163    this.language = language;
     164    this.value = value;
     165    }
     166    /** Ensure this is a valid metadata entry by checking that the value is non-null and non-zero length (after having removed whitespace).
    167167      * @return <i>true</i> if this metadata has a valid value and should be added to the config, <i>false</i> otherwise.
    168168      */
    169     public boolean valid() {
    170           return(value != null && value.trim().length() > 0);
    171     }
     169    public boolean valid() {
     170    return(value != null && value.trim().length() > 0);
     171    }
    172172}
    173173
Note: See TracChangeset for help on using the changeset viewer.