001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.locator;
018:
019: /**
020: * Jetspeed default Locator Descriptor implementation
021: *
022: * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
023: * @version $Id: JetspeedLocatorDescriptor.java 516448 2007-03-09 16:25:47Z ate $
024: */
025: public class JetspeedLocatorDescriptor implements LocatorDescriptor {
026: public JetspeedLocatorDescriptor() {
027: }
028:
029: private String type;
030: private String name;
031: private String mediaType;
032: private String language;
033: private String country;
034: private static final String DELIM = "/";
035:
036: /* (non-Javadoc)
037: * @see java.lang.Object#toString()
038: */
039: public String toString() {
040: StringBuffer value = new StringBuffer();
041:
042: // type
043: if (type != null) {
044: value.append(LocatorDescriptor.PARAM_TYPE).append(DELIM);
045: value.append(type).append(DELIM);
046: }
047:
048: // media type
049: if (mediaType != null) {
050: value.append(LocatorDescriptor.PARAM_MEDIA_TYPE).append(
051: DELIM);
052: value.append(mediaType).append(DELIM);
053: }
054:
055: // language
056: if (language != null) {
057: value.append(LocatorDescriptor.PARAM_LANGUAGE)
058: .append(DELIM);
059: value.append(language).append(DELIM);
060: }
061:
062: // country
063: if (country != null) {
064: value.append(LocatorDescriptor.PARAM_COUNTRY).append(DELIM);
065: value.append(country).append(DELIM);
066: }
067:
068: // template name
069: if (name != null) {
070: value.append(LocatorDescriptor.PARAM_NAME).append(DELIM);
071: value.append(name).append(DELIM);
072: }
073:
074: value.deleteCharAt(value.length() - 1);
075: return value.toString();
076:
077: }
078:
079: /* (non-Javadoc)
080: * @see org.apache.jetspeed.cps.template.TemplateLocator#toPath()
081: */
082: public String toPath() {
083: StringBuffer value = new StringBuffer("/");
084:
085: // type
086: if (type != null) {
087: value.append(type).append(DELIM);
088: }
089:
090: // media type
091: if (mediaType != null) {
092: value.append(mediaType).append(DELIM);
093: }
094:
095: // language
096: if (language != null) {
097: value.append(language).append(DELIM);
098: }
099:
100: // country
101: if (country != null) {
102: value.append(country).append(DELIM);
103: }
104:
105: // template name
106: if (name != null) {
107: value.append(name).append(DELIM);
108: }
109:
110: value.deleteCharAt(value.length() - 1);
111: return value.toString();
112:
113: }
114:
115: /* (non-Javadoc)
116: * @see org.apache.jetspeed.cps.template.TemplateLocator#getType()
117: */
118: public String getType() {
119: return type;
120: }
121:
122: /* (non-Javadoc)
123: * @see org.apache.jetspeed.cps.template.TemplateLocator#setType(java.lang.String)
124: */
125: public void setType(String type) {
126: this .type = type;
127: }
128:
129: /* (non-Javadoc)
130: * @see org.apache.jetspeed.cps.template.TemplateLocator#getName()
131: */
132: public String getName() {
133: return name;
134: }
135:
136: /* (non-Javadoc)
137: * @see org.apache.jetspeed.cps.template.TemplateLocator#setName(java.lang.String)
138: */
139: public void setName(String name) {
140: this .name = name;
141: }
142:
143: /* (non-Javadoc)
144: * @see org.apache.jetspeed.cps.template.TemplateLocator#getMediaType()
145: */
146: public String getMediaType() {
147: return mediaType;
148: }
149:
150: /* (non-Javadoc)
151: * @see org.apache.jetspeed.cps.template.TemplateLocator#setMediaType(java.lang.String)
152: */
153: public void setMediaType(String mediaType) {
154: this .mediaType = mediaType;
155: }
156:
157: /* (non-Javadoc)
158: * @see org.apache.jetspeed.cps.template.TemplateLocator#getLanguage()
159: */
160: public String getLanguage() {
161: return language;
162: }
163:
164: /* (non-Javadoc)
165: * @see org.apache.jetspeed.cps.template.TemplateLocator#setLanguage(java.lang.String)
166: */
167: public void setLanguage(String language) {
168: this .language = language;
169: }
170:
171: /* (non-Javadoc)
172: * @see org.apache.jetspeed.cps.template.TemplateLocator#getCountry()
173: */
174: public String getCountry() {
175: return country;
176: }
177:
178: /* (non-Javadoc)
179: * @see org.apache.jetspeed.cps.template.TemplateLocator#setCountry(java.lang.String)
180: */
181: public void setCountry(String country) {
182: this .country = country;
183: }
184:
185: /**
186: * @see Object#clone
187: * @return an instance copy of this object
188: */
189: public Object clone() throws java.lang.CloneNotSupportedException {
190: return super.clone();
191: }
192:
193: }
|