Source Code Cross Referenced for PGPropMultiVal.java in  » Science » Cougaar12_4 » org » cougaar » tools » csmart » core » cdata » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » org.cougaar.tools.csmart.core.cdata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * <copyright>
003:         *  
004:         *  Copyright 2001-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */
026:        package org.cougaar.tools.csmart.core.cdata;
027:
028:        import org.cougaar.tools.csmart.util.ArgValue;
029:
030:        import java.io.Serializable;
031:        import java.util.ArrayList;
032:        import java.util.Iterator;
033:        import java.util.List;
034:
035:        /**
036:         * Holds a single set of values. These values might be
037:         * <code>String</code>s, or might be name-value pairs.
038:         **/
039:        public class PGPropMultiVal implements  Serializable {
040:            private List values; // of Strings or of name/value pairs
041:
042:            /**
043:             * Creates a new <code>PGPropMultiVal</code> instance.
044:             *
045:             */
046:            public PGPropMultiVal() {
047:                this .values = new ArrayList();
048:            }
049:
050:            /**
051:             * Creates a new <code>PGPropMultiVal</code> instance with the given values.
052:             * Note that the values must be <code>String</code>s ar <code>ArgValue</code>s
053:             *
054:             * @param newValues an <code>Object[]</code> array of values
055:             */
056:            //   public PGPropMultiVal(Object[] newValues) {
057:            //     this.values = new ArrayList();
058:            //     this.setValues(newValues);
059:            //   }
060:            public PGPropMultiVal(Object newValues) {
061:                if (newValues instanceof  List)
062:                    this .values = (List) newValues;
063:                else if (newValues.getClass().isArray()) {
064:                    this .values = new ArrayList();
065:                    this .setValues((Object[]) newValues);
066:                }
067:            }
068:
069:            /**
070:             * Sets all values for this Property
071:             *
072:             * @param newValues Object[] array of values
073:             */
074:            public void setValues(Object[] newValues) {
075:                this .values.clear();
076:                for (int i = 0; i < newValues.length; i++) {
077:                    if (!(newValues[i] instanceof  String)
078:                            && !(newValues[i] instanceof  ArgValue)) {
079:                        throw new RuntimeException(
080:                                "Value must be a String or ArgValue ["
081:                                        + newValues[i] + "],, but is a "
082:                                        + newValues[i].getClass().toString());
083:                        //newValues[i] = newValues[i].toString();
084:                    }
085:                    this .values.add(newValues[i]);
086:                }
087:            }
088:
089:            /**
090:             * Adds a value for this Property
091:             *
092:             * @param value for this property
093:             */
094:            public void addValue(String value) {
095:                this .values.add(value);
096:            }
097:
098:            /**
099:             * Adds a value for this Property
100:             *
101:             * @param value as an ArgValue
102:             */
103:            public void addValue(ArgValue value) {
104:                this .values.add(value);
105:            }
106:
107:            /**
108:             * Sets a value for this Property, replacing the previous value at this index
109:             *
110:             * @param index for value
111:             * @param value to replace with
112:             */
113:            public void setValue(int index, String value)
114:                    throws IndexOutOfBoundsException {
115:                this .values.set(index, value);
116:            }
117:
118:            /**
119:             * Sets a value for this Property, replacing the previous value at this index
120:             *
121:             * @param index for value
122:             * @param value as ArgValue to replace with
123:             */
124:            public void setValue(int index, ArgValue value)
125:                    throws IndexOutOfBoundsException {
126:                this .values.set(index, value);
127:            }
128:
129:            /**
130:             * Returns an array of values for this property.
131:             *
132:             * @return values
133:             */
134:            public String[] getValuesStringArray() {
135:                // Do type checking!!!
136:                return (String[]) values.toArray(new String[values.size()]);
137:            }
138:
139:            /**
140:             * Returns an array of values for this property.
141:             *
142:             * @return values
143:             */
144:            public ArgValue[] getValuesArgValueArray() {
145:                // Do type checking!!
146:                return (ArgValue[]) values.toArray(new ArgValue[values.size()]);
147:            }
148:
149:            /**
150:             * Returns an array of values for this property.
151:             *
152:             * @return values
153:             */
154:            public Object[] getValuesObjectArray() {
155:                // Do type checking!!
156:                return values.toArray();
157:            }
158:
159:            /**
160:             * Returns an iterator of values for this property.
161:             *
162:             * @return iterator
163:             */
164:            public Iterator getValuesIterator() {
165:                return values.iterator();
166:            }
167:
168:            /**
169:             * Returns a count of all values for this property.
170:             *
171:             * @return count
172:             */
173:            public int getValueCount() {
174:                return values.size();
175:            }
176:
177:            public String toString() {
178:                StringBuffer buf = new StringBuffer();
179:                if (values.size() > 0) {
180:                    buf.append(values.get(0));
181:                    for (int i = 1; i < values.size(); i++) {
182:                        buf.append(", " + values.get(i));
183:                    }
184:                }
185:                return buf.toString();
186:            }
187:
188:        } // end of PGPropMultiVal.java
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.