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

import com.adobe.xmp.schema.model.ArrayType;
import com.adobe.xmp.schema.model.PropertyDescription;
import com.adobe.xmp.schema.model.PropertyType;
import com.adobe.xmp.schema.model.SchemaDescription;
import com.adobe.xmp.schema.model.TypeRegistry;
import com.adobe.xmp.schema.model.UnspecifiedType;
import com.adobe.xmp.schema.model.impl.PropertyDescriptionImpl;
import com.adobe.xmp.schema.model.impl.SchemaDescriptionImpl;
import com.adobe.xmp.schema.model.impl.TypeRegistryImpl;

public class SchemaModelFactoryImpl {
    public static SchemaDescription createSchema(String namespaceURI) {
        return new SchemaDescriptionImpl(namespaceURI);
    }

    public static PropertyDescription createProperty(String namespaceURI, String localName, PropertyType type) {
        PropertyDescriptionImpl property = new PropertyDescriptionImpl(localName, type);
        property.setNamespaceURI(namespaceURI);
        if (type instanceof UnspecifiedType) {
            ((UnspecifiedType)type).addReference(property);
        } else if (type instanceof ArrayType && ((ArrayType)type).getItemType() instanceof UnspecifiedType) {
            ((UnspecifiedType)((ArrayType)type).getItemType()).addReference(property);
        }
        return property;
    }

    public static TypeRegistry createTypeRegistry(boolean supportRuntimeDecorators) {
        return new TypeRegistryImpl(supportRuntimeDecorators);
    }
}