View Javadoc
1   /*
2    * Copyright 2010 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.fatwire.gst.foundation.properties;
17  
18  import java.io.Serializable;
19  
20  import com.fatwire.assetapi.data.AssetId;
21  import com.fatwire.gst.foundation.facade.assetapi.AssetIdUtils;
22  
23  /**
24   * TODO: Add class/interface details
25   *
26   * @author Tony Field
27   * @since 11-09-02
28   */
29  final class PropertyImpl implements Property, Serializable {
30      /**
31  	 * 
32  	 */
33  	private static final long serialVersionUID = 692797066527955686L;
34  	String name;
35      String description;
36      String value;
37      PropertyImpl(String name, String description, String value) {
38          this.name = name;
39          this.value = value;
40      }
41      public String getName() {
42          return name;
43      }
44      public String getDescription() {
45          return description;
46      }
47      public boolean isNull() {
48          return value == null;
49      }
50      public boolean asBoolean() {
51          return Boolean.getBoolean(value);
52      }
53      public String asString() {
54          return value;
55      }
56      public long asLong() {
57          return Long.valueOf(value);
58      }
59      public int asInt() {
60          return Integer.valueOf(value);
61      }
62      public AssetId asAssetId() {
63          return AssetIdUtils.fromString(value);
64      }
65  
66      public String toString() {
67          return "GSTProperty:"+name+"="+value; // todo: smart password suppression
68      }
69  }