001/**
002 * Copyright 2015 DuraSpace, Inc.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.fcrepo.oai.service;
017
018import org.openarchives.oai._2.MetadataFormatType;
019import org.openarchives.oai._2.ObjectFactory;
020
021/**
022 * Metadata form Representation for OAI Provider
023 *
024 * @author Frank Asseg
025 */
026public class MetadataFormat {
027
028    private String prefix;
029
030    private String schemaUrl;
031
032    private String namespace;
033
034    private String propertyName;
035
036    /**
037     * Get the property name used for the metadata format
038     *
039     * @return the property name
040     */
041    public String getPropertyName() {
042        return propertyName;
043    }
044
045    /**
046     * Get the prefix for this metadata format used in oai representations
047     *
048     * @return the prefix
049     */
050    public String getPrefix() {
051        return prefix;
052    }
053
054    /**
055     * Get this metadata format's XML schema url
056     *
057     * @return the URL of the XSD
058     */
059    public String getSchemaUrl() {
060        return schemaUrl;
061    }
062
063    /**
064     * get the namespace for this metadata format
065     *
066     * @return the namespace
067     */
068    public String getNamespace() {
069        return namespace;
070    }
071
072    /**
073     * Get the metadata format as a OAI schema compliant type used by JAX-B for serialization
074     *
075     * @return the OAI metadata format type
076     */
077    public MetadataFormatType asMetadataFormatType() {
078        final ObjectFactory objectFactory = new ObjectFactory();
079        final MetadataFormatType type = objectFactory.createMetadataFormatType();
080        type.setSchema(schemaUrl);
081        type.setMetadataNamespace(namespace);
082        type.setMetadataPrefix(prefix);
083        return type;
084
085    }
086
087    /**
088     * Sets prefix.
089     *
090     * @param prefix the prefix
091     */
092    public void setPrefix(final String prefix) {
093        this.prefix = prefix;
094    }
095
096    /**
097     * Sets schema url.
098     *
099     * @param schemaUrl the schema url
100     */
101    public void setSchemaUrl(final String schemaUrl) {
102        this.schemaUrl = schemaUrl;
103    }
104
105    /**
106     * Sets namespace.
107     *
108     * @param namespace the namespace
109     */
110    public void setNamespace(final String namespace) {
111        this.namespace = namespace;
112    }
113
114    /**
115     * Sets property name.
116     *
117     * @param propertyName the property name
118     */
119    public void setPropertyName(final String propertyName) {
120        this.propertyName = propertyName;
121    }
122}