All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.coffi.CONSTANT_Utf8_info Maven / Gradle / Ivy

There is a newer version: 2.5.0-9
Show newest version
/* Soot - a J*va Optimization Framework
 * Copyright (C) 1997 Clark Verbrugge
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/*
 * Modified by the Sable Research Group and others 1997-1999.  
 * See the 'credits' file distributed with Soot for the complete list of
 * contributors.  (Soot is distributed at http://www.sable.mcgill.ca/soot)
 */


package soot.coffi;
import soot.*;
import soot.jimple.StringConstant;

import java.io.*;

import javax.naming.OperationNotSupportedException;

/** A constant pool entry of type CONSTANT_Utf8; note this is not
 * multithread safe.  It is, however, immutable.
 * @see cp_info
 * @author Clark Verbrugge
 */
public class CONSTANT_Utf8_info extends cp_info {
   // Some local private objects to help with efficient comparisons.
   private int sHashCode;
   // for caching the conversion.
   private String s;
   /** Byte array of actual utf8 string. */
   private final byte bytes[];
   /** Constructor from a DataInputSream */
   public CONSTANT_Utf8_info(DataInputStream d) throws IOException {
          int len;
          len = d.readUnsignedShort();
          bytes = new byte[len+2];
          bytes[0] = (byte)(len>>8);
          bytes[1] = (byte)(len & 0xff);
          if (len>0) {
          int j;
                 for (j=0; jtrue if they are equal, false if they are not.
    */
   public boolean equals(CONSTANT_Utf8_info cu) {
      int i,j;
      j = bytes.length;
      if (j!=cu.bytes.length) return false;
      for (i=0; i0 indicating whether this is smaller,
    * the same or larger than cp.
    * @see cp_info#compareTo
    * @see CONSTANT_Utf8_info#compareTo(cp_info)
    */
   public int compareTo(cp_info constant_pool[],cp_info cp,cp_info cp_constant_pool[]) {
      return compareTo(cp);
   }
   /** Compares this entry with another cp_info object; note that for Utf8
    * object it really doesn't matter whether they're in the same or a different
    * constant pool, since they really do carry all their data.
    * @param cp constant pool entry to compare against.
    * @return a value <0, 0, or >0 indicating whether this is smaller,
    * the same or larger than cp.
    * @see cp_info#compareTo
    * @see CONSTANT_Utf8_info#compareTo(cp_info[],cp_info,cp_info[])
    */
   public int compareTo(cp_info cp) {
      if (tag!=cp.tag) return tag-cp.tag;
      CONSTANT_Utf8_info cu = (CONSTANT_Utf8_info)cp;
      G.v().coffi_CONSTANT_Utf8_info_e1.reset(bytes);
      G.v().coffi_CONSTANT_Utf8_info_e2.reset(cu.bytes);
      for (;G.v().coffi_CONSTANT_Utf8_info_e1.hasMoreElements() && G.v().coffi_CONSTANT_Utf8_info_e2.hasMoreElements();) {
         G.v().coffi_CONSTANT_Utf8_info_e1.nextElement();
         G.v().coffi_CONSTANT_Utf8_info_e2.nextElement();
         if (G.v().coffi_CONSTANT_Utf8_info_e1.c




© 2015 - 2024 Weber Informatics LLC | Privacy Policy