SchemaDescriptionImpl.java 2.37 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xmp.schema.model.impl;

import com.adobe.xmp.schema.model.PropertyDescription;
import com.adobe.xmp.schema.model.SchemaDescription;
import com.adobe.xmp.schema.model.SchemaVisitor;
import com.adobe.xmp.schema.model.XMPSchemaException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public class SchemaDescriptionImpl
implements SchemaDescription {
    private String namespaceURI;
    private ArrayList<PropertyDescription> properties = new ArrayList();
    private String label;
    private String description;

    SchemaDescriptionImpl(String namespaceURI) {
        if (namespaceURI == null || namespaceURI.length() == 0) {
            throw new IllegalArgumentException("The namespaceURI must not be empty.");
        }
        this.namespaceURI = namespaceURI;
    }

    @Override
    public String getNamespaceURI() {
        return this.namespaceURI;
    }

    @Override
    public String getLabel() {
        return this.label;
    }

    @Override
    public void setLabel(String label) {
        this.label = label;
    }

    @Override
    public String getDescription() {
        return this.description;
    }

    @Override
    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public void addProperty(PropertyDescription property) {
        property.setNamespaceURI(this.namespaceURI);
        this.properties.add(property);
    }

    @Override
    public PropertyDescription getProperty(String localName) {
        for (PropertyDescription property : this.properties) {
            if (!property.getName().equals(localName)) continue;
            return property;
        }
        return null;
    }

    @Override
    public void removeProperty(String localName) {
        Iterator<PropertyDescription> it = this.properties.iterator();
        while (it.hasNext()) {
            PropertyDescription property = it.next();
            if (!property.getName().equals(localName)) continue;
            it.remove();
        }
    }

    public ArrayList<PropertyDescription> getProperties() {
        return this.properties;
    }

    @Override
    public void accept(SchemaVisitor visitor) throws XMPSchemaException {
        visitor.visit(this);
    }
}