Ignore:
Timestamp:
02/13/14 14:42:31 (10 years ago)
Author:
twagoo
Message:

Written marshaller/unmarshaller for VloConfig?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/DataRoot.java

    r4480 r4509  
    1 
    21package eu.clarin.cmdi.vlo.config;
    32
    43import java.io.File;
    5 import org.simpleframework.xml.Element;
    6 import org.simpleframework.xml.Root;
     4import javax.xml.bind.annotation.XmlElement;
     5import javax.xml.bind.annotation.XmlRootElement;
    76
    87/**
    98 * A dataRoot describes the meta data sources.
    10  * 
     9 *
    1110 * In an XML file, a dataRoot is reflected like this:<br><br>
    12  * 
    13  * {@literal <DataRoot>} 
     11 *
     12 * {@literal <DataRoot>}
    1413 *      {@literal<originName>}name{@literal</originName>}
    1514 *      {@literal<rootFile>}topLevelMetadataDirectory/{@literal</rootFile>}
     
    1817 *      {@literal<deleteFirst>}falseOrTrue{@literal</deleteFirst>}
    1918 * {@literal</DataRoot>}
    20  * 
     19 *
    2120 * @author keeloo
    2221 */
    23 @Root // Simple directive
     22@XmlRootElement(name = "DataRoot")
    2423public class DataRoot extends Object {
    25    
     24
    2625    /**
    2726     * Constructor method
    2827     */
    29     public DataRoot (){
    30     }
    31    
     28    public DataRoot() {
     29    }
     30
    3231    /**
    3332     * Constructor method
    34      * 
     33     *
    3534     * @param originName name describing the meta data
    3635     * @param rootFile top level directory in which the meta data is stored
    3736     * @param prefix left part of the rootFile
    38      * @param toStrip if you want to create the URL to the meta data, this is 
     37     * @param toStrip if you want to create the URL to the meta data, this is
    3938     * the part to be removed from the rootFile
    40      * @param deleteFirst 
     39     * @param deleteFirst
    4140     */
    4241    public DataRoot(String originName, File rootFile, String prefix, String toStrip, Boolean deleteFirst) {
     
    4443        this.rootFile = rootFile;
    4544        this.prefix = prefix;
    46         this.tostrip = toStrip;
     45        this.toStrip = toStrip;
    4746        this.deleteFirst = deleteFirst;
    4847    }
    49    
     48
    5049    /**
    5150     * Test for equality of the object itself and the object passed to it
    52      * 
     51     *
    5352     * @param dataRoot
    5453     * @return true if the object equals this, false otherwise
    5554     */
    5655    @Override
    57     public boolean equals (Object object){
     56    public boolean equals(Object object) {
    5857        boolean equal = false;
    59        
     58
    6059        if (object == null) {
    6160            // define this object to be different from nothing
    6261        } else {
    63             if (! (object instanceof DataRoot)) {
     62            if (!(object instanceof DataRoot)) {
    6463                // the object is not a DataRoot, define it not to be equal
    6564            } else {
     
    6766                equal = this.rootFile.equals(((DataRoot) object).rootFile) && equal;
    6867                equal = this.prefix.equals(((DataRoot) object).prefix) && equal;
    69                 equal = this.tostrip.equals(((DataRoot) object).tostrip) && equal;
     68                equal = this.toStrip.equals(((DataRoot) object).toStrip) && equal;
    7069
    7170                equal = this.deleteFirst == ((DataRoot) object).deleteFirst && equal;
    7271            }
    7372        }
    74        
     73
    7574        return equal;
    7675    }
     
    7877    /**
    7978     * Generate by the ide
    80      * 
     79     *
    8180     * @return hash code
    8281     */
     
    8786        hash = 29 * hash + (this.rootFile != null ? this.rootFile.hashCode() : 0);
    8887        hash = 29 * hash + (this.prefix != null ? this.prefix.hashCode() : 0);
    89         hash = 29 * hash + (this.tostrip != null ? this.tostrip.hashCode() : 0);
     88        hash = 29 * hash + (this.toStrip != null ? this.toStrip.hashCode() : 0);
    9089        hash = 29 * hash + (this.deleteFirst ? 1 : 0);
    9190        return hash;
     
    9594     * name describing the meta data
    9695     */
    97     @Element // Simple directive
    9896    private String originName;
    99  
     97
    10098    /**
    10199     * top level directory in which the meta data is stored
    102100     */
    103     @Element
    104101    private File rootFile;
    105    
    106     /**
    107      * Web equivalent of the toStrip. For example: 
    108      * 
     102
     103    /**
     104     * Web equivalent of the toStrip. For example:
     105     *
    109106     * /lat/apache/htdocs/
    110107     */
    111     @Element 
    112108    private String prefix;
    113109
    114110    /**
    115      * Left part of the rootFile 
     111     * Left part of the rootFile
    116112     *
    117113     * By first removing {@literal tostrip} from {@literal rootFile} and then
     
    119115     * the URL to the meta data.
    120116     */
    121     @Element
    122     private String tostrip;
    123    
     117    @XmlElement(name = "tostrip")
     118    private String toStrip;
     119
    124120    /**
    125121     * Flag to signal the removal of records from the Solr server
    126      * 
    127      * The value of this flag overrides the value defined in the {@lieteral
    128      * VloConfig.xml} file. With the deleteFirst flag you can control the
    129      * removal of the records originating from originName.
    130      */
    131     @Element
     122     *
     123     * The value of this flag overrides the value defined in the {
     124     *
     125     * @lieteral VloConfig.xml} file. With the deleteFirst flag you can control
     126     * the removal of the records originating from originName.
     127     */
    132128    private boolean deleteFirst = false;
    133129
     
    135131     * Get the value of the prefix element<br><br>
    136132     *
    137      * For a description of the element, refer to the general VLO
    138      * documentation.
     133     * For a description of the element, refer to the general VLO documentation.
    139134     *
    140135     * @return the value
     
    147142     * Set the value of the prefix element<br><br>
    148143     *
    149      * For a description of the element, refer to the general VLO
    150      * documentation.
     144     * For a description of the element, refer to the general VLO documentation.
    151145     *
    152146     * @param prefix the value
     
    159153     * Get the value of the {@literal tostrip} element<br><br>
    160154     *
    161      * For a description of the element, refer to the general VLO
    162      * documentation.
     155     * For a description of the element, refer to the general VLO documentation.
    163156     *
    164157     * @return the value
    165158     */
    166159    public String getToStrip() {
    167         return tostrip;
     160        return toStrip;
    168161    }
    169162
     
    171164     * Set the value of the {@literal tostrip} element<br><br>
    172165     *
    173      * For a description of the element, refer to the general VLO
    174      * documentation.
     166     * For a description of the element, refer to the general VLO documentation.
    175167     *
    176168     * @param tostrip the value
    177169     */
    178170    public void setTostrip(String tostrip) {
    179         this.tostrip = tostrip;
     171        this.toStrip = tostrip;
    180172    }
    181173
     
    183175     * Get the value of the originName element<br><br>
    184176     *
    185      * For a description of the element, refer to the general VLO
    186      * documentation.
    187      *
    188      * @return the value
    189      */   
     177     * For a description of the element, refer to the general VLO documentation.
     178     *
     179     * @return the value
     180     */
    190181    public String getOriginName() {
    191182        return originName;
     
    195186     * Set the value of the originName element<br><br>
    196187     *
    197      * For a description of the element, refer to the general VLO
    198      * documentation.
     188     * For a description of the element, refer to the general VLO documentation.
    199189     *
    200190     * @param originName the value
    201      */   
     191     */
    202192    public void setOriginName(String originName) {
    203193        this.originName = originName;
     
    207197     * Get the value of the rootFile element<br><br>
    208198     *
    209      * For a description of the element, refer to the general VLO
    210      * documentation.
    211      *
    212      * @return the value
    213      */   
     199     * For a description of the element, refer to the general VLO documentation.
     200     *
     201     * @return the value
     202     */
    214203    public File getRootFile() {
    215204        return rootFile;
     
    219208     * Set the value of the rootFile element<br><br>
    220209     *
    221      * For a description of the element, refer to the general VLO
    222      * documentation.
     210     * For a description of the element, refer to the general VLO documentation.
    223211     *
    224212     * @param rootFile the value
    225      */   
     213     */
    226214    public void setRootFile(File rootFile) {
    227215        this.rootFile = rootFile;
     
    231219     * Set the value of the deleteFirst element<br><br>
    232220     *
    233      * For a description of the element, refer to the general VLO
    234      * documentation.
     221     * For a description of the element, refer to the general VLO documentation.
    235222     *
    236223     * @param deleteFirst the value
    237      */   
     224     */
    238225    public void setDeleteFirst(boolean deleteFirst) {
    239226        this.deleteFirst = deleteFirst;
     
    243230     * Get the value of the deleteFirst element<br><br>
    244231     *
    245      * For a description of the element, refer to the general VLO
    246      * documentation.
    247      *
    248      * @return the value
    249      */   
     232     * For a description of the element, refer to the general VLO documentation.
     233     *
     234     * @return the value
     235     */
    250236    public boolean deleteFirst() {
    251237        return deleteFirst;
    252238    }
     239
     240    @Override
     241    public String toString() {
     242        return String.format("originName: %s; rootFile: %s; prefix: %s; toStrip: %s; deleteFirst: %b", originName, rootFile, prefix, toStrip, deleteFirst);
     243    }
     244
    253245}
    254 
Note: See TracChangeset for help on using the changeset viewer.