• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Arrays类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.squawk.util.Arrays的典型用法代码示例。如果您正苦于以下问题:Java Arrays类的具体用法?Java Arrays怎么用?Java Arrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Arrays类属于com.sun.squawk.util包,在下文中一共展示了Arrays类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: charToByteArray

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
 * Convert a byte array to a char array
 *
 * @param  buffer          The byte array buffer
 * @param  offset          The offset
 * @param  length          The length
 * @param  enc             The character encoding
 * @return                 A new char array
 * @exception UnsupportedEncodingException  If the encoding is not known
 */
public static byte[] charToByteArray(char[] buffer, int offset, int length, String enc) throws UnsupportedEncodingException {
    Arrays.boundsCheck(buffer.length, offset, length);
    //Because most cases use ISO8859_1 encoding, we can optimize this case.
    if (isISO8859_1(enc)) {
        if (length < 0) {
            throw new IndexOutOfBoundsException();
        }
        byte[] value = new byte[length];
        for(int i=0; i<length; i++) {
            //c = buffer[i+offset];
            //value[i] = (c <= 255) ? (byte)c : (byte)'?'; TCK doesn't like seeing this '?'
            value[i] = (byte)buffer[i+offset];
        }
        return value;
    } else if (ISO8859_1_ONLY_SUPPORTED) {
        throw new UnsupportedEncodingException("ISO8859_1_ONLY_SUPPORTED: " + enc);
    } else {
        return charToByteArray0(buffer, offset, length, enc);
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:31,代码来源:Helper.java


示例2: strip

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
 * Creates a stripped copy of an array of MethodMetadata. The value of <code>metadatas</code>
 * is not modified. The line number tables are stripped if {@link #preserveLineNumberTables}
 * has not been called. The local variable tables are stripped if {@link #preserveLineNumberTables}
 * has not been called.
 *
 * @param metadatas  the array to create a stripped copy of
 * @return the stripped copy of <code>metadatas</code>
 */
static MethodMetadata[] strip(MethodMetadata[] metadatas) {
    if (metadatas != null) {
        if (preserveLineNumberTables || preserveLocalVariableTables) {
            SquawkVector temp = new SquawkVector(metadatas.length);
            for (int i = 0; i != metadatas.length; ++i) {
                MethodMetadata md = metadatas[i];
                if (md != null) {
                    temp.addElement(md.strip(preserveLineNumberTables, preserveLocalVariableTables));
                }
            }
            if (temp.size() == 0) {
                return null;
            }
            
            MethodMetadata[] result = new MethodMetadata[temp.size()];
            temp.copyInto(result);
            Arrays.sort(result, new MethodMetadataComparer());
            return result;
        }
    }
    return null;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:32,代码来源:MethodMetadata.java


示例3: getManifestProperty

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
 * Gets the value of an {@link Suite#PROPERTIES_MANIFEST_RESOURCE_NAME} property embedded in the suite.
 *
 * @param name the name of the property whose value is to be retrieved
 * @return the property value
 */
String getManifestProperty(String name) {
	int index = Arrays.binarySearch(manifestProperties, name, ManifestProperty.comparer);
       if (index < 0) {
           // To support dynamic class loading we need to follow the same semantics as Klass.forName
           // which is to look to see if we can't dynamically load a property if its not found
           if (isClosed() || isPropertiesManifestResourceInstalled) {
               return null;
           }
           // The following should automatically install the properties if there is a manifest
           InputStream input = getResourceAsStream(PROPERTIES_MANIFEST_RESOURCE_NAME, null);
           if (input != null) {
               try {input.close();} catch (IOException e) {/*nothing*/};
           }
           isPropertiesManifestResourceInstalled = true;
           index = Arrays.binarySearch(manifestProperties, name, ManifestProperty.comparer);
           if (index < 0) {
               return null;
           }
       }
	return manifestProperties [index].value;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:28,代码来源:Suite.java


示例4: installProperty

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
	 * Installs a collection of IMlet property values into this suite.
	 *
	 * @param property IMlet property to install
	 */
	public void installProperty(ManifestProperty property) {
		checkWrite();
        // There could be more than one manifest property for a given key,
        // as is the case if JAD properties are added, so take this into account
        int index = Arrays.binarySearch(manifestProperties, property.name, ManifestProperty.comparer);
        if (index < 0) {
/*if[ENABLE_VERBOSE]*/	    	    
            if (VM.isVerbose()) {
                System.out.println("[Adding property key: |" + property.name + "| value: |" + property.value + "|]");
            }
/*end[ENABLE_VERBOSE]*/	    	    
            System.arraycopy(manifestProperties, 0, manifestProperties = new ManifestProperty[manifestProperties.length + 1], 0, manifestProperties.length - 1);
            manifestProperties[manifestProperties.length - 1] = property;
            Arrays.sort(manifestProperties, ManifestProperty.comparer);
        } else {
/*if[ENABLE_VERBOSE]*/	    	    
            if (VM.isVerbose()) {
                System.out.println("[Overwriting property key: |" + property.name + "| value: |" + property.value + "|]");
            }
/*end[ENABLE_VERBOSE]*/	    	    
            manifestProperties[index] = property;
        }
	}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:29,代码来源:Suite.java


示例5: traceType

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
 * Traces a type on the operand stack or in a local variable.
 *
 * @param type       the type to trace
 * @param prefix     the prefix to use if <code>isDerived</code> is true
 *                   otherwise a prefix of spaces the same length as
 *                   <code>prefix</code> is used instead
 * @param isDerived  specifies if this a type derived by the verifer or
 *                   is specified by a stack map entry
 */
private void traceType(Klass type, String prefix, boolean isDerived) {
    if (Translator.TRACING_ENABLED) {
        if (!isDerived) {
            char[] spaces = new char[prefix.length()];
            Arrays.fill(spaces, ' ');
            Tracer.trace(new String(spaces));
        } else {
            Tracer.trace(prefix);
        }
        String name = (type == null ? "-T-" : type.getInternalName());
        if (isDerived) {
            Tracer.traceln(" "+name);
        } else {
            Tracer.traceln("{"+name+"}");
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:28,代码来源:Frame.java


示例6: sortFields

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
 * Sorts an array of fields by the data size of their types in
 * descending order.
 *
 * @param fields  the array of fields to sort
 */
private void sortFields(ClassFileField[] fields) {
    Arrays.sort(fields, new Comparer() {
        public int compare(Object o1, Object o2) {
            if (o1 == o2) {
                return 0;
            }

            Klass t1 = ((ClassFileField)o1).getType();
            Klass t2 = ((ClassFileField)o2).getType();

            /*
             * Sort by data size of field's type
             */
            if (t1.getDataSize() < t2.getDataSize()) {
                return 1;
            } else if (t1.getDataSize() > t2.getDataSize()) {
                return -1;
            } else {
                return 0;
            }
        }
    });
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:30,代码来源:ClassFileLoader.java


示例7: replaceConstructor

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
 * Substitutes the body of a given constructor method with the body of a matching method
 * from a set of given replacement methods. A replacement method matches the constructor
 * if it takes the same set of parameter types.
 *
 * @param ctor         the constructor whose body is to be replaced
 * @param replacements the set of methods to search for a match
 * @return the new constructor once the substitution has been done
 * @throws LinkageError if no substitution could be found
 */
private ClassFileMethod replaceConstructor(ClassFileMethod ctor, SquawkVector replacements) {
    if (replacements != null) {

        Klass[] types = ctor.getParameterTypes();
        Klass[] matchTypes = new Klass[types.length + 1];
        System.arraycopy(types, 0, matchTypes, 1, types.length);
        matchTypes[0] = klass;

        for (Enumeration e = replacements.elements(); e.hasMoreElements(); ) {
            ClassFileMethod method = (ClassFileMethod)e.nextElement();

            if (Arrays.equals(matchTypes, method.getParameterTypes())) {
                ctor = new ClassFileMethod("<init>",
                    ctor.getModifiers() | Modifier.METHOD_HAS_PRAGMAS,
                    ctor.getReturnType(),
                    ctor.getParameterTypes(),
                    ctor.getPragmas() | PragmaException.REPLACEMENT_CONSTRUCTOR);
                ctor.setCode(method.getCode());
                return ctor;
            }
        }
    }
    throw new com.sun.squawk.translator.VerifyError(prefix("could not match original constructor with a replacement constructor"));
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:35,代码来源:ClassFileLoader.java


示例8: init

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
protected final void init(INorFlashSectorState[] sectorStates) {
    Arrays.sort(sectorStates, new Comparer() {
        public int compare(Object a, Object b) {
            Address aStart = ((INorFlashSectorState) a).getStartAddress();
            Address bStart = ((INorFlashSectorState) b).getStartAddress();
            if (aStart.eq(bStart)) {
                return 0;
            }
            if (aStart.lo(bStart)) {
                return -1;
            }
            return +1;
        }
    });
    this.sectorStates = sectorStates;
    erasedSequenceCurrentValue = 0;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:18,代码来源:NorFlashMemoryHeap.java


示例9: installProperty

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
 * Installs a collection of IMlet property values into this suite.
 *
 * @param property IMlet property to install
 */
public void installProperty(ManifestProperty property) {
	checkWrite();
       // There could be more than one manifest property for a given key,
       // as is the case if JAD properties are added, so take this into account
       int index = Arrays.binarySearch(manifestProperties, property.name, ManifestProperty.comparer);
       if (index < 0) {
           if (VM.isVerbose()) {
               System.out.println("[Adding property key: |" + property.name + "| value: |" + property.value + "|]");
           }
           System.arraycopy(manifestProperties, 0, manifestProperties = new ManifestProperty[manifestProperties.length + 1], 0, manifestProperties.length - 1);
           manifestProperties[manifestProperties.length - 1] = property;
           Arrays.sort(manifestProperties, ManifestProperty.comparer);
       } else {
           if (VM.isVerbose()) {
               System.out.println("[Overwriting property key: |" + property.name + "| value: |" + property.value + "|]");
           }
           manifestProperties[index] = property;
       }
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:25,代码来源:Suite.java


示例10: getFormattedString

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
public String getFormattedString(int zoneLength)
   {
       if(m_updateString)
{
           m_updateString = false;
           if(m_stringHeader.length() + m_stringData.length() > zoneLength)
           {
               if(m_stringData.length() > zoneLength)
               {
                   m_formattedString = m_stringData.substring( 0, zoneLength);
               }
               else
               {
                   m_formattedString = m_stringHeader.substring(0, zoneLength - m_stringData.length()) + m_stringData;
               }
           }
           else
           {
               byte[] tmp = new byte[zoneLength - (m_stringHeader.length() + m_stringData.length())];
               Arrays.fill(tmp, (byte)' ');
               m_formattedString = m_stringHeader + new String(tmp).concat(m_stringData);
           }	
}		
return m_formattedString;
   }
 
开发者ID:SaintsRobotics,项目名称:Woodchuck-2013,代码行数:26,代码来源:StringData.java


示例11: getLineTwo

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
String getLineTwo()
   {
       byte[] tmp = new byte[m_zoneLength];
       Arrays.fill(tmp, (byte)'-');        
       String tmpString = new String(tmp);
	
if(m_infoItems.size() > 1)
{
	if(m_scrollPosition + 1 >= (int)m_infoItems.size())
	{
		tmpString = ((DisplayData)m_infoItems.elementAt(0)).getFormattedString(m_zoneLength);
	}
	else
	{
		tmpString = ((DisplayData)m_infoItems.elementAt(m_scrollPosition + 1)).getFormattedString(m_zoneLength);
	}
}
return tmpString;
   }
 
开发者ID:SaintsRobotics,项目名称:Woodchuck-2013,代码行数:20,代码来源:Zone.java


示例12: getFormattedString

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
public String getFormattedString(int zoneLength)
   {
       if(m_updateString)
{
           m_updateString = false;
           String tmpString = Integer.toString(m_integerData);
           if(m_integerHeader.length() + tmpString.length() > zoneLength)
           {                
               if(tmpString.length() > zoneLength)
               {
                       tmpString = new String( tmpString.substring( 0, (tmpString.length() - (tmpString.length() - zoneLength) - 1)));
               }
               m_formattedString = m_integerHeader.substring(0, zoneLength - tmpString.length()) + tmpString;
           }
           else
           {
               byte[] tmp = new byte[zoneLength - (m_integerHeader.length() + tmpString.length())];
               Arrays.fill(tmp, (byte)' ');
               m_formattedString = m_integerHeader + new String(tmp).concat(tmpString);
           }	
}		
return m_formattedString;
   }
 
开发者ID:SaintsRobotics,项目名称:Woodchuck-2013,代码行数:24,代码来源:IntegerData.java


示例13: getFormattedString

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
public String getFormattedString(int zoneLength)
   {
       if(m_updateString)
{
           m_updateString = false;
           String tmpString = formatDecimal(m_floatData);            
           
           if(m_floatHeader.length() + tmpString.length() > zoneLength)
           {                
               if(tmpString.length() > zoneLength)
               {
                       tmpString = tmpString.substring( 0, (tmpString.length() - (tmpString.length() - zoneLength) - 1));
               }
               m_formattedString = m_floatHeader.substring(0, zoneLength - tmpString.length()) + tmpString;
           }
           else
           {
               byte[] tmp = new byte[zoneLength - (m_floatHeader.length() + tmpString.length())];
               Arrays.fill(tmp, (byte)' ');
               m_formattedString = m_floatHeader + new String(tmp).concat(tmpString);
           }	
}		
return m_formattedString;
   }
 
开发者ID:SaintsRobotics,项目名称:Woodchuck-2013,代码行数:25,代码来源:DecimalData.java


示例14: formatDecimal

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
private String formatDecimal(double convert)
{
    int exp = 10;
    for(int i = 1; i < m_precision; i++)
    {
        exp *= 10;
    }
    int wholePart = (int)convert;
    double decimalPart = convert - wholePart;
    int convertedDecimal = (int)((decimalPart * exp) + .5);
    String tmpDecimal = Integer.toString(convertedDecimal);
    if(tmpDecimal.length() < m_precision)
    {
        byte[] extraZeros = new byte[m_precision - tmpDecimal.length()];
        Arrays.fill(extraZeros, (byte)'0');
        tmpDecimal = new String(extraZeros).concat(tmpDecimal);
    }        
    return new String(Integer.toString(wholePart) + '.' + tmpDecimal);
}
 
开发者ID:SaintsRobotics,项目名称:Woodchuck-2013,代码行数:20,代码来源:DecimalData.java


示例15: write

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
public void write(byte b[], int off, int len) throws IOException {
    Arrays.boundsCheck(b.length, off, len);
    if (len == 0) {
        return;
    }
    int old;
    if (err) {
        old = VM.setStream(VM.STREAM_STDERR);
    } else {
        old = VM.setStream(VM.STREAM_STDOUT);
    }
    VM.printBytes(b, off, len);
    VM.setStream(old);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:15,代码来源:System.java


示例16: verify

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
	 * Verifies a buffer 
     * @param buffer 
     * @param bufferOffset 
     * @param bufferLength 
     * @param signature 
     * @param signatureOffset 
     * @param signatureLength
     * @todo javadoc
	 * @throws SignatureVerifierException
	 */
	public static void verify(byte[] buffer, int bufferOffset, int bufferLength, byte[] signature, int signatureOffset,
			int signatureLength) throws SignatureVerifierException {
		ensureInitialized();
		byte[] result = new byte[20];

/*if[NATIVE_VERIFICATION]*/
    	Address address=Address.fromObject((buffer));
    	address=address.addOffset(Offset.fromPrimitive(bufferOffset));
    	if (SignatureVerifier.DEBUG) {
    		System.out.println("verify using native SHA1.\n\t Address for compute hash : "+address.toUWord().toInt()+
    				"Includes Offset: "+bufferOffset);
        }
    	VM.execSyncIO(ChannelConstants.INTERNAL_COMPUTE_SHA1_FOR_MEMORY_REGION,address.toUWord().toInt(), bufferLength , 0, 0, 0, 0, result, null);
		
		result = Arrays.copy(result, 0, 20, 0, 20);
		if (SignatureVerifier.DEBUG) {
			System.out.println("Hash computed using NATIVE function: \n"+HexEncoding.hexEncode(result));
        }
/*else[NATIVE_VERIFICATION]*/	
//	md.reset();
//  md.doFinal(buffer, bufferOffset, bufferLength, result, 0);
//  if (SignatureVerifier.DEBUG)		
//			System.out.println("Hash computed using Java class: \n"+HexEncoding.hexEncode(result));
//		
/*end[NATIVE_VERIFICATION]*/
		if (!verifyMessageDigest(result, signature,signatureOffset,signatureLength)) {
			throw new SignatureVerifierException("Signature verification failed");
		}
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:41,代码来源:SignatureVerifier.java


示例17: getMetadata0

import com.sun.squawk.util.Arrays; //导入依赖的package包/类
/**
 * Gets the <code>KlassMetadata</code> instance from this suite
 * corresponding to a specified class.
 *
 * @param    klass  a class
 * @return   the <code>KlassMetadata</code> instance corresponding to
 *                <code>klass</code> or <code>null</code> if there isn't one
 */
KlassMetadata getMetadata0(Klass klass) {
    if (metadatas != null /*&& contains(klass)*/) {
        int metaindex = Arrays.binarySearch(metadatas, klass, KlassMetadata.comparer);
        if (metaindex >= 0) {
            KlassMetadata metadata = metadatas[metaindex];
            Assert.that(metadata != null);
            Assert.that(metadata.getDefinedClass() == klass, "metadata.getDefinedClass(): " + metadata.getDefinedClass() + " klass: " + klass);
            return metadata;
        }
    }
    Assert.that(searchForMetadata(klass) == null);
    return null;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:22,代码来源:Suite.java



注:本文中的com.sun.squawk.util.Arrays类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileSystemStructureProvider类代码示例发布时间:2022-05-23
下一篇:
Java DJIError类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap