All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.enhydra.xml.xmlc.metadata.URLEdit Maven / Gradle / Ivy

The newest version!
/*
 * Enhydra Java Application Server Project
 * 
 * The contents of this file are subject to the Enhydra Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License on
 * the Enhydra web site ( http://www.enhydra.org/ ).
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
 * the License for the specific terms governing rights and limitations
 * under the License.
 * 
 * The Initial Developer of the Enhydra Application Server is Lutris
 * Technologies, Inc. The Enhydra Application Server and portions created
 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
 * All Rights Reserved.
 * 
 * Contributor(s):
 * 
 * $Id: URLEdit.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
 */

package org.enhydra.xml.xmlc.metadata;

import org.enhydra.xml.xmlc.XMLCException;
import org.w3c.dom.Document;

/**
 * Abstract type uses as a base for all URL editing definition.
 */
public abstract class URLEdit extends ElementEdit {
    /**
     * Attribute names.
     */
    private static final String EDIT_ATTRS_ATTR = "editAttrs";
    
    /**
     * Cache of parsed attributes.
     */
    private String[] editAttrs;

    /**
     * Constructor.
     */
    protected URLEdit(Document ownerDoc,
                      String tagName) {
    	super(ownerDoc, tagName);
    }

    /**
     * Get the editAttrs value.
     */
    public String[] getEditAttrs() {
        return getStringArrayAttribute(EDIT_ATTRS_ATTR);
    }

    /**
     * Set the editAttrs attribute value.
     */
    public void setEditAttrs(String[] values) {
        setRemoveStringArrayAttribute(EDIT_ATTRS_ATTR, values);
    }

    /**
     * Add an attribute name to the editAttr attribute value.
     */
    public void addEditAttrs(String value) {
        addStringArrayAttribute(EDIT_ATTRS_ATTR, value);
    }

    /**
     * Determine if an id matches the element id constraints on
     * this object.  If there are no id constraints, all elements
     * match.
     */
    public boolean matchesEditAttrConstraints(String attrName,
                                              boolean ignoreCase) {
        if (editAttrs == null) {
            editAttrs = getEditAttrs();
        }
        if (editAttrs.length == 0) {
            return true;
        }
        if (ignoreCase) {
            for (int idx = 0; idx < editAttrs.length; idx++) {
                if (attrName.equalsIgnoreCase(editAttrs[idx])) {
                    return true;
                }
            }
        } else {
            for (int idx = 0; idx < editAttrs.length; idx++) {
                if (attrName.equals(editAttrs[idx])) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * Complete modifications to DOM.  This clears cache of parsed
     * attributes.
     * @see MetaDataElement#completeModifications
     */
    protected void completeModifications() throws XMLCException {
        super.completeModifications();
        editAttrs = null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy