Source Code Cross Referenced for ArgValue.java in  » Science » Cougaar12_4 » org » cougaar » tools » csmart » util » 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.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 2000-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:
027:        package org.cougaar.tools.csmart.util;
028:
029:        import java.io.Serializable;
030:
031:        /**
032:         * An argument name (a String), and its value, an arbitrary object (possibly null).
033:         * Construct one with the arg name and the Object value.  Alternatively, a convenience
034:         * constructor allows you to supply a string, and a separator in that string
035:         * which separates the Arg and the Value.
036:         * Note that the argument cannot be null, and in this case the value is a String
037:         *
038:         * @see Serializable
039:         */
040:        public class ArgValue implements  Serializable {
041:            private String arg;
042:            private Object value;
043:
044:            /**
045:             * Creates a new <code>ArgValue</code> instance.
046:             *
047:             * @param arg a <code>String</code> argument (non-null)
048:             * @param value an <code>Object</code> value
049:             */
050:            public ArgValue(String arg, Object value) {
051:                if (arg == null) {
052:                    // error!
053:                    throw new IllegalArgumentException(
054:                            "Need a non-null argument");
055:                }
056:                this .arg = arg;
057:                this .value = value;
058:            }
059:
060:            /**
061:             * Creates a new <code>ArgValue</code> instance.
062:             * The pair is a string with both arg and value in it, with an arbitrary separator.
063:             * Note that this works only for the case where the value is a String
064:             *
065:             * @param pair a <code>String</code> Containing both Arg and Value
066:             * @param sep a <code>String</code> that separates Arg and Value
067:             */
068:            public ArgValue(String pair, String sep) {
069:                // the pair must be split on sep to produce arg and value
070:                if (pair == null || sep == null) {
071:                    // error!
072:                    throw new IllegalArgumentException(
073:                            "Can't parse with null Strings");
074:                }
075:
076:                int start = pair.indexOf(sep);
077:                if (start < 1) {
078:                    // error!
079:                    throw new IllegalArgumentException(
080:                            "Separator not found, or null Argument");
081:                }
082:
083:                int stop = start + sep.length();
084:
085:                //this(pair.substring(0, start), pair.substring(stop, pair.length() - 1));
086:                this .arg = pair.substring(0, start);
087:                if (this .arg == null) {
088:                    throw new IllegalArgumentException(
089:                            "Need a non-null argument");
090:                }
091:                this .value = pair.substring(stop, pair.length());
092:            }
093:
094:            /**
095:             * Creates a new <code>ArgValue</code> instance.
096:             * Take a string containg both the argument and the value
097:             * Assume the separator is " = "
098:             * Note that this works only for the case where the value is a String
099:             *
100:             * @param pair a <code>String</code> with arg and value
101:             */
102:            public ArgValue(String pair) {
103:                this (pair, " = ");
104:            }
105:
106:            /**
107:             * @return a <code>String</code> Argument
108:             */
109:            public String getArg() {
110:                return this .arg;
111:            }
112:
113:            /**
114:             * @return an <code>Object</code> Value, possibly null
115:             */
116:            public Object getValue() {
117:                return this .value;
118:            }
119:
120:            /**
121:             * Override the current value for this ArgValue pair with a new value
122:             * Use with caution!
123:             *
124:             * @param val an <code>Object</code> value for this ArgValue pair
125:             */
126:            public void setValue(Object val) {
127:                this .value = val;
128:            }
129:
130:            /**
131:             * Two ArgValues are equal if BOTH the Argument and the value are String.equals
132:             *
133:             * @param o an <code>Object</code> to compare
134:             * @return a <code>boolean</code>, true if equal
135:             */
136:            public boolean equals(Object o) {
137:                if (o instanceof  ArgValue) {
138:                    ArgValue t = (ArgValue) o;
139:                    if (t.getValue() != null) {
140:                        return ((t.getValue().equals(this .value)) && (t
141:                                .getArg().equals(this .arg)));
142:                    } else {
143:                        return (this .value == null && (t.getArg()
144:                                .equals(this .arg)));
145:                    }
146:                }
147:                return super .equals(o);
148:            }
149:
150:            public String toString() {
151:                if (this .value != null) {
152:                    return (this .arg + " = " + this .value.toString());
153:                } else {
154:                    return (this .arg + " = (null)");
155:                }
156:            }
157:        } // ArgValue.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.