Ignore:
Timestamp:
2005-01-25T16:32:41+13:00 (19 years ago)
Author:
mdewsnip
Message:

More GEMS improvements, by Matthew Whyte. Now has subfield support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gems/ElementWrapper.java

    r8881 r8930  
    6161    private String namespace = "";
    6262
     63    private NodeList subelements = null; //The list of subelements
     64
    6365    private Troolean is_extracted = new Troolean();
    6466    /** Constructor for elements with no namespace necessary.
     
    6971    //System.err.println("ElementWrapper: element is: " + element); //debug
    7072    Element parent =  (Element)element.getParentNode();
    71     if (parent != null) {
    72         this.namespace = parent.getAttribute("namespace");
    73     }
    74 
     73    if (parent != null)
     74        {
     75        this.namespace = parent.getAttribute("namespace");
     76        }
     77   
     78    subelements = element.getElementsByTagName("Subelement");
     79    //Should read in each subelement's value tree?
    7580    }
    7681
     
    8186    public void addAttribute(String name, String language, String value) {
    8287    MSMUtils.addElementAttribute(element, name, language, value);
     88    }
     89
     90
     91    /**
     92       Check to see if the element contains a particular subelement
     93       @return true if element already contains a subelement of name name.
     94       @param name the name of the subelement to check for, as a <strong>String</strong>
     95       @author Matthew Whyte
     96       @date last modified: 19/01/04
     97    */
     98    public boolean containsSubelement(String name)
     99    {
     100    //System.err.println("Want to see if subelement: " + name + " exists."); //debug
     101    for(int i = 0; i < subelements.getLength(); i++)
     102        {
     103        Element sibling = (Element)subelements.item(i);
     104        String sibling_name = sibling.getAttribute("name");
     105        if(sibling_name.equals(name))
     106            {
     107            return true;
     108            }
     109        }
     110       
     111    return false;
     112    }
     113
     114    /**
     115       Method to acquire a list of all the subelements in the element.
     116       @return A <strong>NodeList</strong> containing all of this element's subelements.
     117
     118       @author: Matthew Whyte
     119       @date last modified: 19/01/04
     120     */
     121    public NodeList getSubelements()
     122    {
     123    return subelements;
     124    }
     125
     126    /**
     127       Method to determine if this is a subelement
     128       @return A <strong>boolean</strong> - true if the 'element' is a subelement
     129       @author Matthew Whyte
     130       @date last modified 19/01/04
     131     */
     132    public boolean isSubelement()
     133    {
     134    Element element = this.getElement();
     135    if(element.getTagName().equals("Subelement"))
     136        {
     137        return true;
     138        }
     139    return false;
    83140    }
    84141
     
    137194    return MSMUtils.getIdentifier(element);
    138195    }
     196
     197    /** Retrieve the name of this element. Name is unique.
     198    @return The name (without the namespace) as a <strong>String</strong>.
     199    @see org.greenstone.gatherer.msm.MSMUtils
     200    @author Matthew Whyte
     201    @date last modified: 21/01/04
     202     */
     203    public String getNameOnly() {
     204    return MSMUtils.getNameOnly(element);
     205    }
     206
    139207    /** Retrieve the name of this element. Name is unique.
    140208     * @return The name as a <strong>String</strong>.
     
    142210     */
    143211    public String getName() {
    144     return MSMUtils.getFullName(element, namespace);
    145     }
     212        return MSMUtils.getFullName(element, namespace);
     213    }
     214
     215
    146216    /** Retrieve the namespace prefix for this element wrapper.
    147217     * @return A <strong>String</strong> containing the namespace or "" if there is no namespace for this element.
Note: See TracChangeset for help on using the changeset viewer.