jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java
author joehw
Sun, 13 Aug 2017 21:10:40 -0700
changeset 46174 5611d2529b49
parent 45853 bfa06be36a17
permissions -rw-r--r--
8163121: BCEL: update to the latest 6.0 release Reviewed-by: dfuchs, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
45853
bfa06be36a17 8181154: Fix lint warnings in JAXP repo: deprecation
joehw
parents: 44797
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 */
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     4
/*
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     5
 * 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
     6
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * 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
     9
 * (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
    10
 * 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
    11
 *
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    12
 *      http://www.apache.org/licenses/LICENSE-2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    14
 * 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
    15
 * 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
    16
 * 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
    17
 * See the License for the specific language governing permissions and
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    18
 * limitations under the License.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    19
 */
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    20
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
package com.sun.org.apache.bcel.internal.classfile;
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    23
import java.io.DataInput;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    24
import java.io.DataOutputStream;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    25
import java.io.IOException;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    27
import com.sun.org.apache.bcel.internal.Const;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
/**
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    30
 * This class is derived from the abstract {@link Constant}
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 * and represents a reference to a long object.
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 *
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    33
 * @version $Id: ConstantLong.java 1747278 2016-06-07 17:28:43Z britter $
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 * @see     Constant
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
public final class ConstantLong extends Constant implements ConstantObject {
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    37
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    38
    private long bytes;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    39
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    40
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    41
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    42
     * @param bytes Data
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    43
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    44
    public ConstantLong(final long bytes) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    45
        super(Const.CONSTANT_Long);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    46
        this.bytes = bytes;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    47
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    48
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    49
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    50
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    51
     * Initialize from another object.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    52
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    53
    public ConstantLong(final ConstantLong c) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    54
        this(c.getBytes());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    55
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    56
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    57
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    58
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    59
     * Initialize instance from file data.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    60
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    61
     * @param file Input stream
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    62
     * @throws IOException
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    63
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    64
    ConstantLong(final DataInput file) throws IOException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    65
        this(file.readLong());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    66
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    67
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    68
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    69
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    70
     * Called by objects that are traversing the nodes of the tree implicitely
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    71
     * defined by the contents of a Java class. I.e., the hierarchy of methods,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    72
     * fields, attributes, etc. spawns a tree of objects.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    73
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    74
     * @param v Visitor object
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    75
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    76
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    77
    public void accept( final Visitor v ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    78
        v.visitConstantLong(this);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    79
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    80
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    82
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    83
     * Dump constant long to file stream in binary format.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    84
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    85
     * @param file Output file stream
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    86
     * @throws IOException
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    87
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    88
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    89
    public final void dump( final DataOutputStream file ) throws IOException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    90
        file.writeByte(super.getTag());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    91
        file.writeLong(bytes);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    92
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    93
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    94
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    95
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    96
     * @return data, i.e., 8 bytes.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    97
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    98
    public final long getBytes() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
    99
        return bytes;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   100
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   101
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   103
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   104
     * @param bytes the raw bytes that represent this long
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   105
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   106
    public final void setBytes( final long bytes ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   107
        this.bytes = bytes;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   108
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   109
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   110
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   111
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   112
     * @return String representation.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   113
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   114
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   115
    public final String toString() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   116
        return super.toString() + "(bytes = " + bytes + ")";
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   117
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   118
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   119
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   120
    /** @return Long object
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   121
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   122
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   123
    public Object getConstantValue( final ConstantPool cp ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   124
        return Long.valueOf(bytes);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 45853
diff changeset
   125
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
}