author | joehw |
Mon, 17 Apr 2017 16:24:10 -0700 | |
changeset 44797 | 8b3b3b911b8a |
parent 25868 | 686eef1e7a79 |
child 45853 | bfa06be36a17 |
permissions | -rw-r--r-- |
6 | 1 |
/* |
2 |
* reserved comment block |
|
3 |
* DO NOT REMOVE OR ALTER! |
|
4 |
*/ |
|
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
5 |
/* |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
6 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
7 |
* contributor license agreements. See the NOTICE file distributed with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
8 |
* this work for additional information regarding copyright ownership. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
9 |
* The ASF licenses this file to You under the Apache License, Version 2.0 |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
10 |
* (the "License"); you may not use this file except in compliance with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
11 |
* the License. You may obtain a copy of the License at |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
12 |
* |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
13 |
* http://www.apache.org/licenses/LICENSE-2.0 |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
14 |
* |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
15 |
* Unless required by applicable law or agreed to in writing, software |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
16 |
* distributed under the License is distributed on an "AS IS" BASIS, |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
17 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
18 |
* See the License for the specific language governing permissions and |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
19 |
* limitations under the License. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
20 |
*/ |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
21 |
|
6 | 22 |
package com.sun.org.apache.bcel.internal.classfile; |
23 |
||
24 |
||
25 |
import com.sun.org.apache.bcel.internal.Constants; |
|
26 |
import java.io.*; |
|
27 |
||
28 |
/** |
|
29 |
* This class is derived from the abstract |
|
30 |
* <A HREF="com.sun.org.apache.bcel.internal.classfile.Constant.html">Constant</A> class |
|
31 |
* and represents a reference to a long object. |
|
32 |
* |
|
33 |
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> |
|
34 |
* @see Constant |
|
35 |
*/ |
|
36 |
public final class ConstantLong extends Constant implements ConstantObject { |
|
37 |
private long bytes; |
|
38 |
||
39 |
/** |
|
40 |
* @param bytes Data |
|
41 |
*/ |
|
42 |
public ConstantLong(long bytes) |
|
43 |
{ |
|
44 |
super(Constants.CONSTANT_Long); |
|
45 |
this.bytes = bytes; |
|
46 |
} |
|
47 |
/** |
|
48 |
* Initialize from another object. |
|
49 |
*/ |
|
50 |
public ConstantLong(ConstantLong c) { |
|
51 |
this(c.getBytes()); |
|
52 |
} |
|
53 |
/** |
|
54 |
* Initialize instance from file data. |
|
55 |
* |
|
56 |
* @param file Input stream |
|
57 |
* @throws IOException |
|
58 |
*/ |
|
59 |
ConstantLong(DataInputStream file) throws IOException |
|
60 |
{ |
|
61 |
this(file.readLong()); |
|
62 |
} |
|
63 |
/** |
|
64 |
* Called by objects that are traversing the nodes of the tree implicitely |
|
65 |
* defined by the contents of a Java class. I.e., the hierarchy of methods, |
|
66 |
* fields, attributes, etc. spawns a tree of objects. |
|
67 |
* |
|
68 |
* @param v Visitor object |
|
69 |
*/ |
|
70 |
public void accept(Visitor v) { |
|
71 |
v.visitConstantLong(this); |
|
72 |
} |
|
73 |
/** |
|
74 |
* Dump constant long to file stream in binary format. |
|
75 |
* |
|
76 |
* @param file Output file stream |
|
77 |
* @throws IOException |
|
78 |
*/ |
|
79 |
public final void dump(DataOutputStream file) throws IOException |
|
80 |
{ |
|
81 |
file.writeByte(tag); |
|
82 |
file.writeLong(bytes); |
|
83 |
} |
|
84 |
/** |
|
85 |
* @return data, i.e., 8 bytes. |
|
86 |
*/ |
|
87 |
public final long getBytes() { return bytes; } |
|
88 |
/** |
|
89 |
* @param bytes. |
|
90 |
*/ |
|
91 |
public final void setBytes(long bytes) { |
|
92 |
this.bytes = bytes; |
|
93 |
} |
|
94 |
/** |
|
95 |
* @return String representation. |
|
96 |
*/ |
|
97 |
public final String toString() { |
|
98 |
return super.toString() + "(bytes = " + bytes + ")"; |
|
99 |
} |
|
100 |
||
101 |
/** @return Long object |
|
102 |
*/ |
|
103 |
public Object getConstantValue(ConstantPool cp) { |
|
104 |
return new Long(bytes); |
|
105 |
} |
|
106 |
} |