⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 counter64.java

📁 CmisJavaApi
💻 JAVA
字号:
/* * The contents of this file are subject to the Dyade Public License,  * as defined by the file DYADE_PUBLIC_LICENSE.TXT * * You may not use this file except in compliance with the License. You may * obtain a copy of the License on the Dyade web site (www.dyade.fr). * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific terms governing rights and limitations under the License. * * The Original Code is CmisJava API, including the java package  * fr.dyade.cmis, released September 5, 2000. * * The Initial Developer of the Original Code is Dyade. The Original Code and * portions created by Dyade are Copyright Bull and Copyright INRIA.  * All Rights Reserved. *//*      Copyright 1996-2000 by Institut National de Recherche en Informatique  *                             et en Automatique (INRIA) *          All rights reserved.  See COPYRIGHT in top-level directory. * *      Authors: Laurent Andrey, Eric Dillon, Olivier Festor */// $Id: Counter64.java,v 1.2 2000/09/05 13:30:36 festor Exp $// $Source: /local/resedas/CVS-Repository/CmisJavaApi/src/fr/dyade/cmis/api/types/Counter64.java,v $//// TODO// Add a "cache" for frequently used Counter64.// REMARK: BigInteger.ZERO is "since 1.2". Arch !!package fr.dyade.cmis.api.types;import java.math.BigInteger;/** Support for ASN1 Counter64.  * Counter 64 is an <b>unsigned</b> 64 bits integer.  * It is implemented by two signed 64 bits integers (java long).  * It is a litle messy implementation but....  * A conversion back and forth to java.math.BigInteger is provided  * if user needs a full set of arithmetic operations.  */public class Counter64 extends Value {      // Java respect textual order for class initialization      private static final BigInteger ZERO_BI=new BigInteger(new byte[] {0});      private static final BigInteger MAX_VALUE_BI=new BigInteger(+1, new byte[]{-1, -1, -1, -1, -1, -1, -1, -1});// 64 bits all 1.      public static final Counter64 MAX_VALUE=new Counter64(MAX_VALUE_BI);      public Counter64(long pMostSignificant32bits, long pLeastSignificant32bits) {	 super(VALUE_COUNTER64);	 // unsigned 64 bits	 fValue=new BigInteger(+1, new byte[] {				  (byte)(pMostSignificant32bits>>>24),				  (byte)(pMostSignificant32bits>>>16),				  (byte)(pMostSignificant32bits>>>8),	  				  (byte)pMostSignificant32bits,				  (byte)(pLeastSignificant32bits>>>24),				  (byte)(pLeastSignificant32bits>>>16),				  (byte)(pLeastSignificant32bits>>>8),				  (byte)pLeastSignificant32bits});      }      public Counter64() {	 super(VALUE_COUNTER32);	 fValue=ZERO_BI;      }      public Counter64( byte[] pValue ) {	 super(VALUE_COUNTER64);	 if (pValue.length>8) {	    throw new IllegalArgumentException("Counter64 is at most 8 bytes unsigned");	 } else {	    // UNSIGNED 64 bits.	    fValue=new BigInteger(+1, pValue);	 }      }      public Counter64( BigInteger pValue ) {	 super(VALUE_COUNTER64);	 //No value checking. we assume that "isValid" is check before mapping.	 fValue=pValue;      }      public String toString() {	 return fValue.toString();      }      /** Convert this Counter64 to a big integer.	* @return the internal immutable BigInteger 	*/      public BigInteger bigIntegerValue(){	 //Rmk: BigInteger has no method to change its state, immutable	 return fValue;      }      public boolean isValid() {	 // see BigInteger.compareTo() java doc suggested idiom for this operation.	 return (ZERO_BI.compareTo(fValue)<=0) && (fValue.compareTo(MAX_VALUE_BI)<=0);      }      private BigInteger fValue;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -