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 com.fatwire.assetapi.data.AssetId;
19  import com.fatwire.gst.foundation.facade.assetapi.AssetIdUtils;
20  
21  /**
22   * TODO: Add class/interface details
23   *
24   * @author Tony Field
25   * @since 11-09-02
26   */
27  final class PropertyImpl implements Property {
28      String name;
29      String description;
30      String value;
31      PropertyImpl(String name, String description, String value) {
32          this.name = name;
33          this.value = value;
34      }
35      public String getName() {
36          return name;
37      }
38      public String getDescription() {
39          return description;
40      }
41      public boolean isNull() {
42          return value == null;
43      }
44      public boolean asBoolean() {
45          return Boolean.getBoolean(value);
46      }
47      public String asString() {
48          return value;
49      }
50      public long asLong() {
51          return Long.valueOf(value);
52      }
53      public int asInt() {
54          return Integer.valueOf(value);
55      }
56      public AssetId asAssetId() {
57          return AssetIdUtils.fromString(value);
58      }
59  
60      public String toString() {
61          return "GSTProperty:"+name+"="+value; // todo: smart password suppression
62      }
63  }