01: /*
02: * $Id: EnvironmentEntry.java 752 2006-11-10 21:16:47Z hengels $
03: * (c) Copyright 2004 con:cern development team.
04: *
05: * This file is part of con:cern (http://concern.sf.net).
06: *
07: * con:cern is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU Lesser General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.concern.model;
15:
16: import java.io.Serializable;
17: import java.lang.reflect.Constructor;
18:
19: /**
20: * @author hengels[at]mercatis[dot]de
21: * @version $Revision: 752 $
22: */
23: public class EnvironmentEntry implements Serializable {
24: String name;
25: String description;
26: String type = "java.lang.String";
27: String value;
28: public static final Object[] TYPES = new Object[] {
29: "java.lang.Boolean", "java.lang.Byte",
30: "java.lang.Character", "java.lang.String",
31: "java.lang.Short", "java.lang.Integer", "java.lang.Long",
32: "java.lang.Float", "java.lang.Double",
33: "java.math.BigInteger", "java.math.BigDecimal",
34: "java.net.URL" };
35:
36: public EnvironmentEntry() {
37: }
38:
39: public EnvironmentEntry(String name, String type, String value) {
40: this .name = name;
41: this .type = type;
42: this .value = value;
43: }
44:
45: public String getName() {
46: return name;
47: }
48:
49: public void setName(String name) {
50: this .name = name;
51: }
52:
53: public String getDescription() {
54: return description;
55: }
56:
57: public void setDescription(String description) {
58: this .description = description;
59: }
60:
61: public String getType() {
62: return type;
63: }
64:
65: public void setType(String type) {
66: this .type = type;
67: }
68:
69: public String getValue() {
70: return value;
71: }
72:
73: public void setValue(String value) {
74: this .value = value;
75: }
76:
77: public String toString() {
78: return "name=" + name + ", type=" + type + ", value=" + value;
79: }
80:
81: public static Object createInstance(String type, String value) {
82: try {
83: Class clazz = Class.forName(type);
84: Constructor constructor = clazz
85: .getConstructor(new Class[] { String.class });
86: return constructor.newInstance(new Object[] { value });
87: } catch (Exception e) {
88: return null;
89: }
90: }
91: }
|