001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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     */
016    package org.kuali.rice.kew.api.document.attribute;
017    
018    import javax.xml.bind.annotation.XmlAccessType;
019    import javax.xml.bind.annotation.XmlAccessorType;
020    import javax.xml.bind.annotation.XmlElement;
021    import javax.xml.bind.annotation.XmlRootElement;
022    import javax.xml.bind.annotation.XmlType;
023    
024    /**
025     * A document attribute which contains character data.  Construct instances of {@code DocumentAttributeString} using
026     * it's builder or the {@link DocumentAttributeFactory}.
027     *
028     * @author Kuali Rice Team (rice.collab@kuali.org)
029     */
030    @XmlRootElement(name = DocumentAttributeString.Constants.ROOT_ELEMENT_NAME)
031    @XmlAccessorType(XmlAccessType.NONE)
032    @XmlType(name = DocumentAttributeString.Constants.TYPE_NAME, propOrder = {
033        DocumentAttributeString.Elements.VALUE
034    })
035    public final class DocumentAttributeString extends DocumentAttribute {
036    
037        @XmlElement(name = Elements.VALUE, required = false)
038        private final String value;
039    
040        @SuppressWarnings("unused")
041        private DocumentAttributeString() {
042            this.value = null;
043        }
044    
045        private DocumentAttributeString(Builder builder) {
046            super(builder.getName());
047            this.value = builder.getValue();
048        }
049    
050        @Override
051        public String getValue() {
052            return value;
053        }
054    
055        @Override
056        public DocumentAttributeDataType getDataType() {
057            return DocumentAttributeDataType.STRING;
058        }
059    
060        /**
061         * A builder implementation which allows for construction of a {@code DocumentAttributeString}.
062         */
063        public static final class Builder extends AbstractBuilder<String> {
064    
065            private Builder(String name) {
066                super(name);
067            }
068    
069            /**
070             * Create a builder for the document attribute using the given attribute name.
071             *
072             * @param name the name of the document attribute which should be built by this builder, should never be a
073             * null or blank value
074             * @return a builder instance initialized with the given attribute name
075             */
076            public static Builder create(String name) {
077                return new Builder(name);
078            }
079    
080            @Override
081            public DocumentAttributeDataType getDataType() {
082                return DocumentAttributeDataType.STRING;
083            }
084    
085            @Override
086            public DocumentAttributeString build() {
087                return new DocumentAttributeString(this);
088            }
089    
090        }
091    
092        /**
093         * Defines some internal constants used on this class.
094         */
095        static class Constants {
096            final static String ROOT_ELEMENT_NAME = "documentAttributeString";
097            final static String TYPE_NAME = "DocumentAttributeStringType";
098        }
099    
100        /**
101         * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
102         */
103        static class Elements {
104            final static String VALUE = "value";
105        }
106    
107    }