Source Code Cross Referenced for SnmpCounter64.java in  » 6.0-JDK-Modules-com.sun » jmx » com » sun » jmx » snmp » 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 » 6.0 JDK Modules com.sun » jmx » com.sun.jmx.snmp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.jmx.snmp;
027:
028:        /**
029:         * Represents an SNMP 64bits counter.
030:         *
031:         * <p><b>This API is a Sun Microsystems internal API  and is subject 
032:         * to change without notice.</b></p>
033:         */
034:
035:        public class SnmpCounter64 extends SnmpValue {
036:            private static final long serialVersionUID = 8784850650494679937L;
037:
038:            // CONSTRUCTORS
039:            //-------------
040:            /**
041:             * Constructs a new <CODE>SnmpCounter64</CODE> from the specified long value.
042:             * @param v The initialization value.
043:             * @exception IllegalArgumentException The specified value is negative
044:             * or larger than <CODE>Long.MAX_VALUE</CODE>. 
045:             */
046:            public SnmpCounter64(long v) throws IllegalArgumentException {
047:
048:                // NOTE:
049:                // The max value for a counter64 variable is 2^64 - 1.
050:                // The max value for a Long is 2^63 - 1.
051:                // All the allowed values for a conuter64 variable cannot be covered !!!
052:                //
053:                if ((v < 0) || (v > Long.MAX_VALUE)) {
054:                    throw new IllegalArgumentException();
055:                }
056:                value = v;
057:            }
058:
059:            /**
060:             * Constructs a new <CODE>SnmpCounter64</CODE> from the specified <CODE>Long</CODE> value.
061:             * @param v The initialization value.
062:             * @exception IllegalArgumentException The specified value is negative
063:             * or larger than <CODE>Long.MAX_VALUE</CODE>. 
064:             */
065:            public SnmpCounter64(Long v) throws IllegalArgumentException {
066:                this (v.longValue());
067:            }
068:
069:            // PUBLIC METHODS
070:            //---------------
071:            /**
072:             * Returns the counter value of this <CODE>SnmpCounter64</CODE>.
073:             * @return The value.
074:             */
075:            public long longValue() {
076:                return value;
077:            }
078:
079:            /**
080:             * Converts the counter value to its <CODE>Long</CODE> form.
081:             * @return The <CODE>Long</CODE> representation of the value.
082:             */
083:            public Long toLong() {
084:                return new Long(value);
085:            }
086:
087:            /**
088:             * Converts the counter value to its integer form.
089:             * @return The integer representation of the value.
090:             */
091:            public int intValue() {
092:                return (int) value;
093:            }
094:
095:            /**
096:             * Converts the counter value to its <CODE>Integer</CODE> form.
097:             * @return The <CODE>Integer</CODE> representation of the value.
098:             */
099:            public Integer toInteger() {
100:                return new Integer((int) value);
101:            }
102:
103:            /**
104:             * Converts the counter value to its <CODE>String</CODE> form.
105:             * @return The <CODE>String</CODE> representation of the value.
106:             */
107:            public String toString() {
108:                return String.valueOf(value);
109:            }
110:
111:            /**
112:             * Converts the counter value to its <CODE>SnmpOid</CODE> form.
113:             * @return The OID representation of the value.
114:             */
115:            public SnmpOid toOid() {
116:                return new SnmpOid(value);
117:            }
118:
119:            /**
120:             * Extracts the counter from an index OID and returns its
121:             * value converted as an <CODE>SnmpOid</CODE>.
122:             * @param index The index array.
123:             * @param start The position in the index array.
124:             * @return The OID representing the counter value.
125:             * @exception SnmpStatusException There is no counter value
126:             * available at the start position.
127:             */
128:            public static SnmpOid toOid(long[] index, int start)
129:                    throws SnmpStatusException {
130:                try {
131:                    return new SnmpOid(index[start]);
132:                } catch (IndexOutOfBoundsException e) {
133:                    throw new SnmpStatusException(
134:                            SnmpStatusException.noSuchName);
135:                }
136:            }
137:
138:            /**
139:             * Scans an index OID, skips the counter value and returns the position
140:             * of the next value.
141:             * @param index The index array.
142:             * @param start The position in the index array.
143:             * @return The position of the next value.
144:             * @exception SnmpStatusException There is no counter value
145:             * available at the start position.
146:             */
147:            public static int nextOid(long[] index, int start)
148:                    throws SnmpStatusException {
149:                if (start >= index.length) {
150:                    throw new SnmpStatusException(
151:                            SnmpStatusException.noSuchName);
152:                } else {
153:                    return start + 1;
154:                }
155:            }
156:
157:            /**
158:             * Appends an <CODE>SnmpOid</CODE> representing an <CODE>SnmpCounter64</CODE> to another OID.
159:             * @param source An OID representing an <CODE>SnmpCounter64</CODE> value.
160:             * @param dest Where source should be appended.
161:             */
162:            public static void appendToOid(SnmpOid source, SnmpOid dest) {
163:                if (source.getLength() != 1) {
164:                    throw new IllegalArgumentException();
165:                }
166:                dest.append(source);
167:            }
168:
169:            /**
170:             * Performs a clone action. This provides a workaround for the
171:             * <CODE>SnmpValue</CODE> interface.
172:             * @return The SnmpValue clone.
173:             */
174:            final synchronized public SnmpValue duplicate() {
175:                return (SnmpValue) clone();
176:            }
177:
178:            /**
179:             * Clones the <CODE>SnmpCounter64</CODE> object, making a copy of its data.
180:             * @return The object clone.
181:             */
182:            final synchronized public Object clone() {
183:                SnmpCounter64 newclone = null;
184:                try {
185:                    newclone = (SnmpCounter64) super .clone();
186:                    newclone.value = value;
187:                } catch (CloneNotSupportedException e) {
188:                    throw new InternalError(); // vm bug.
189:                }
190:                return newclone;
191:            }
192:
193:            /**
194:             * Returns a textual description of the type object.
195:             * @return ASN.1 textual description.
196:             */
197:            final public String getTypeName() {
198:                return name;
199:            }
200:
201:            // VARIABLES
202:            //----------
203:            /**
204:             * Name of the type.
205:             */
206:            final static String name = "Counter64";
207:
208:            /**
209:             * This is where the value is stored. This long is positive.
210:             * @serial
211:             */
212:            private long value = 0;
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.