blob: 63366fd3f934ce4a475dd2f994904f814e588820 [file] [log] [blame]
nitind958d79a2004-11-23 19:23:00 +00001/*******************************************************************************
amywu923ee602007-04-10 18:32:07 +00002 * Copyright (c) 2004, 2005 IBM Corporation and others.
nitind958d79a2004-11-23 19:23:00 +00003 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
amywu923ee602007-04-10 18:32:07 +00007 *
nitind958d79a2004-11-23 19:23:00 +00008 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
david_williams56777022005-04-11 06:21:55 +000011package org.eclipse.wst.html.core.internal.contentmodel.chtml;
nitind958d79a2004-11-23 19:23:00 +000012
david_williams56777022005-04-11 06:21:55 +000013import org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDataType;
david_williamsc06c86f2005-03-18 18:23:41 +000014import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
nitind958d79a2004-11-23 19:23:00 +000015
16
17
18/**
19 */
20class HTMLCMDataTypeImpl extends CMNodeImpl implements HTMLCMDataType {
21
22 private int impliedValueKind = IMPLIED_VALUE_NONE;
23 private String impliedValue = null;
24 private final static String[] emptyArray = new String[0];
25 private String[] enumValues = emptyArray;
26 private String instanceValue = null;
27
28 /**
29 * HTMLCMDataTypeImpl constructor comment.
30 * @param nm java.lang.String
31 */
32 public HTMLCMDataTypeImpl(String typeName) {
33 super(typeName);
34 }
35
36 /**
37 * HTMLCMDataTypeImpl constructor comment.
38 * @param nm java.lang.String
39 */
40 public HTMLCMDataTypeImpl(String typeName, String instanceValue) {
41 super(typeName);
42 this.instanceValue = instanceValue;
43 }
44
45 /**
46 * getTypeName method
47 * @return java.lang.String
48 *
49 * This method returns a suitable default value that can be used when an instance of the data type is created.
50 * This returns null of a suitable default is not available.
51 */
52 public String generateInstanceValue() {
53 return instanceValue;
54 }
55
56 /**
david_williamsc06c86f2005-03-18 18:23:41 +000057 * @see org.eclipse.wst.xml.core.internal.contentmodel.CMDataType
nitind958d79a2004-11-23 19:23:00 +000058 */
59 public String getDataTypeName() {
60 return getNodeName();
61 }
62
63 /**
64 * getTypeName method
65 * @return java.lang.String[]
66 *
67 */
68 public String[] getEnumeratedValues() {
69 return enumValues;
70 }
71
72 /**
73 * getTypeName method
74 * @return java.lang.String
75 *
76 * Returns the implied value or null if none exists.
77 */
78 public String getImpliedValue() {
79 return impliedValue;
80 }
81
82 /**
83 * getImpliedValueKind method
84 * @return int
85 *
86 * Returns one of :
87 * IMPLIED_VALUE_NONE, IMPLIED_VALUE_FIXED, IMPLIED_VALUE_DEFAULT.
88 */
89 public int getImpliedValueKind() {
90 return impliedValueKind;
91 }
92
93 /**
david_williamsc06c86f2005-03-18 18:23:41 +000094 * @see org.eclipse.wst.xml.core.internal.contentmodel.CMNode
nitind958d79a2004-11-23 19:23:00 +000095 */
96 public int getNodeType() {
97 return CMNode.DATA_TYPE;
98 }
99
100 /**
101 */
102 void setEnumValues(String[] values) {
103 enumValues = new String[values.length];
104 for (int i = 0; i < values.length; i++) {
105 enumValues[i] = values[i];
106 }
107 }
108
109 /**
110 * package scope.
111 */
112 void setImpliedValue(int kind, String value) {
113 switch (kind) {
114 case IMPLIED_VALUE_FIXED :
115 case IMPLIED_VALUE_DEFAULT :
116 impliedValueKind = kind;
117 impliedValue = value;
118 break;
119 case IMPLIED_VALUE_NONE :
120 default :
121 impliedValueKind = IMPLIED_VALUE_NONE;
122 impliedValue = null; // maybe a null string?
123 break;
124 }
125 }
amywu923ee602007-04-10 18:32:07 +0000126}