jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java
author joehw
Mon, 17 Apr 2017 16:24:10 -0700
changeset 44797 8b3b3b911b8a
parent 25868 686eef1e7a79
child 45853 bfa06be36a17
permissions -rw-r--r--
8162572: Update License Header for all JAXP sources Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     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
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.bcel.internal.classfile;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import  com.sun.org.apache.bcel.internal.Constants;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import  java.io.*;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
 * This class is derived from the abstract
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
 * <A HREF="com.sun.org.apache.bcel.internal.classfile.Constant.html">Constant</A> class
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 * and represents a reference to a long object.
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
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 {
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
  private long bytes;
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
   * @param bytes Data
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
  public ConstantLong(long bytes)
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
    super(Constants.CONSTANT_Long);
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
    this.bytes = bytes;
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
   * Initialize from another object.
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
  public ConstantLong(ConstantLong c) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
    this(c.getBytes());
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
   * Initialize instance from file data.
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
   * @param file Input stream
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
   * @throws IOException
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
  ConstantLong(DataInputStream file) throws IOException
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
    this(file.readLong());
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
   * Called by objects that are traversing the nodes of the tree implicitely
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
   * defined by the contents of a Java class. I.e., the hierarchy of methods,
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
   * fields, attributes, etc. spawns a tree of objects.
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
   * @param v Visitor object
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
  public void accept(Visitor v) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
    v.visitConstantLong(this);
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
   * Dump constant long to file stream in binary format.
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
   * @param file Output file stream
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
   * @throws IOException
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
  public final void dump(DataOutputStream file) throws IOException
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
    file.writeByte(tag);
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
    file.writeLong(bytes);
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
   * @return data, i.e., 8 bytes.
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
  public final long getBytes() { return bytes; }
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
   * @param bytes.
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
  public final void setBytes(long bytes) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    this.bytes = bytes;
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
   * @return String representation.
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
  public final String toString() {
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
    return super.toString() + "(bytes = " + bytes + ")";
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
  /** @return Long object
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
  public Object getConstantValue(ConstantPool cp) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
    return new Long(bytes);
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
}