Changeset 4502


Ignore:
Timestamp:
2003-06-06T15:41:35+12:00 (21 years ago)
Author:
kjdon
Message:

ElementWrapper now stores the namespace that its element had when it was created. this is passed to MSMUtils getFullName and getFullIdentifier to be used if the element has no parent

File:
1 edited

Legend:

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

    r4467 r4502  
    6464    private Element element = null;
    6565    /** A string prefix identifying the metadata set namespace. */
    66     private String namespace = null;
     66    private String namespace = "";
    6767    /** Constructor for elements with no namespace necessary.
    6868     * @param element The DOM <strong>Element</strong> this is to be based on.
     
    7070    public ElementWrapper(Element element) {
    7171    this.element = element;
     72    Element parent =  (Element)element.getParentNode();
     73    if (parent != null) {
     74        this.namespace = parent.getAttribute("namespace");
     75    }
     76   
    7277    }
    7378    /** Constructor.
    7479      * @param element The DOM <strong>Element</strong> this is to be based on.
     80
    7581      * @param namespace_required <i>true</i> if this element wrapper should always attempt to show a namespace prefix (retrieving it from the DOM if necessary).
    7682      * @deprecated
    7783      */
    78     public ElementWrapper(Element element, boolean namespace_required) {
    79     this(element);
    80     }
     84    //  public ElementWrapper(Element element, boolean namespace_required) {
     85    //this(element);
     86    //  }
    8187
    8288    public void addAttribute(String name, String value) {
     
    113119    public boolean equals(Object object) {
    114120    if(object instanceof ElementWrapper) {
    115         String our_full_name = MSMUtils.getFullName(element);
     121        String our_full_name = MSMUtils.getFullName(element, namespace);
    116122        String their_full_name = MSMUtils.getFullName(((ElementWrapper)object).getElement());
    117123        return our_full_name.equals(their_full_name);
     
    144150      */
    145151    public String getName() {
    146     return MSMUtils.getFullName(element);
     152    return MSMUtils.getFullName(element, namespace);
    147153    }
    148154    /** Retrieve the namespace prefix for this element wrapper.
     
    151157      */
    152158    public String getNamespace() {
     159    if (!namespace.equals("")) {
     160        return namespace;
     161    }
    153162    String name = getName();
    154163    int pos;
     
    218227    }
    219228    public String toString() {
    220     return MSMUtils.getFullIdentifier(element);
     229    return MSMUtils.getFullIdentifier(element, namespace);
    221230    }
    222231}
Note: See TracChangeset for help on using the changeset viewer.