fix copyright header, javadoc, and warnings
This commit is contained in:
1 parent
d970d07048
commit
eb64cc60c5
41 files changed
+1856
-541
No files matched your search
+101
-32
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 MINRES Technologies GmbH and others.
|
||||
* Copyright (c) 2015 - 2020 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -10,34 +10,56 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
/**
|
||||
* The Class BitVector.
|
||||
*/
|
||||
public class BitVector implements IEvent {
|
||||
|
||||
/** The width. */
|
||||
private final int width;
|
||||
|
||||
/** The packed values. */
|
||||
private int[] packedValues;
|
||||
|
||||
/**
|
||||
* Instantiates a new bit vector.
|
||||
*
|
||||
* @param netWidth the net width
|
||||
*/
|
||||
public BitVector(int netWidth) {
|
||||
this.width=netWidth;
|
||||
packedValues = new int[(netWidth+15)/16];
|
||||
for(int i=0; i<packedValues.length; i++) packedValues[i]=0;
|
||||
this.width = netWidth;
|
||||
packedValues = new int[(netWidth + 15) / 16];
|
||||
for (int i = 0; i < packedValues.length; i++)
|
||||
packedValues[i] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
* @param i the i
|
||||
* @param value the value
|
||||
*/
|
||||
public void setValue(int i, BitValue value) {
|
||||
int bitIndex = i*2;
|
||||
int bitIndex = i * 2;
|
||||
int wordOffset = bitIndex >> 5;
|
||||
int bitOffset = bitIndex & 31;
|
||||
packedValues[wordOffset] &= ~(3 << bitOffset);
|
||||
packedValues[wordOffset] |= value.ordinal() << bitOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public char[] getValue() {
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
char[] res = new char[width];
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
int currentWord = (packedValues[wordOffset] >> bitOffset)&3;
|
||||
res[width-i-1]=BitValue.fromInt(currentWord).toChar();
|
||||
int currentWord = (packedValues[wordOffset] >> bitOffset) & 3;
|
||||
res[width - i - 1] = BitValue.fromInt(currentWord).toChar();
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
@@ -47,6 +69,11 @@ public class BitVector implements IEvent {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setValue(char[] value) {
|
||||
int bitIndex = width;
|
||||
int wordOffset = bitIndex >> 4;
|
||||
@@ -61,41 +88,61 @@ public class BitVector implements IEvent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the width.
|
||||
*
|
||||
* @return the width
|
||||
*/
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String toString() {
|
||||
return new String(getValue());
|
||||
}
|
||||
|
||||
public String toHexString(){
|
||||
int resWidth=(width-1)/4+1;
|
||||
char[] value=getValue();
|
||||
/**
|
||||
* To hex string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String toHexString() {
|
||||
int resWidth = (width - 1) / 4 + 1;
|
||||
char[] value = getValue();
|
||||
char[] res = new char[resWidth];
|
||||
for(int i=resWidth-1; i>=0; i--){
|
||||
int digit=0;
|
||||
for(int j=3; j>=0; j--){
|
||||
if((4*i+j)<value.length) {
|
||||
BitValue val = BitValue.fromChar(value[4*i+j]);
|
||||
switch(val) {
|
||||
for (int i = resWidth - 1; i >= 0; i--) {
|
||||
int digit = 0;
|
||||
for (int j = 3; j >= 0; j--) {
|
||||
if ((4 * i + j) < value.length) {
|
||||
BitValue val = BitValue.fromChar(value[4 * i + j]);
|
||||
switch (val) {
|
||||
case X:
|
||||
case Z:
|
||||
res[i]=val.toChar();
|
||||
res[i] = val.toChar();
|
||||
continue;
|
||||
case ONE:
|
||||
digit+=1<<(3-j);
|
||||
digit += 1 << (3 - j);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
res[i]=Character.forDigit(digit, 16); //((digit < 10) ? '0' + digit : 'a' + digit -10)
|
||||
res[i] = Character.forDigit(digit, 16); // ((digit < 10) ? '0' + digit : 'a' + digit -10)
|
||||
}
|
||||
return new String(res);
|
||||
return new String(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* To unsigned value.
|
||||
*
|
||||
* @return the long
|
||||
*/
|
||||
public long toUnsignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
@@ -103,10 +150,11 @@ public class BitVector implements IEvent {
|
||||
int currentWord = 0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
if (bitOffset == 0)
|
||||
currentWord = packedValues[wordOffset];
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res|=1<<i;
|
||||
res |= 1 << i;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
@@ -125,20 +173,26 @@ public class BitVector implements IEvent {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* To signed value.
|
||||
*
|
||||
* @return the long
|
||||
*/
|
||||
public long toSignedValue() {
|
||||
long res = 0;
|
||||
int bitOffset = 0;
|
||||
int wordOffset = 0;
|
||||
int currentWord = 0;
|
||||
int lastVal=0;
|
||||
int lastVal = 0;
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
if(bitOffset==0) currentWord = packedValues[wordOffset];
|
||||
lastVal=0;
|
||||
if (bitOffset == 0)
|
||||
currentWord = packedValues[wordOffset];
|
||||
lastVal = 0;
|
||||
switch (currentWord & 3) {
|
||||
case 1:
|
||||
res|=1<<i;
|
||||
lastVal=1;
|
||||
res |= 1 << i;
|
||||
lastVal = 1;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
@@ -153,24 +207,39 @@ public class BitVector implements IEvent {
|
||||
currentWord >>= 2;
|
||||
}
|
||||
}
|
||||
if(lastVal!=0)
|
||||
res |= -1l<<width;
|
||||
if (lastVal != 0)
|
||||
res |= -1l << width;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the kind.
|
||||
*
|
||||
* @return the kind
|
||||
*/
|
||||
@Override
|
||||
public EventKind getKind() {
|
||||
return EventKind.SINGLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
@Override
|
||||
public WaveformType getType() {
|
||||
return WaveformType.SIGNAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate.
|
||||
*
|
||||
* @return the i event
|
||||
* @throws CloneNotSupportedException the clone not supported exception
|
||||
*/
|
||||
@Override
|
||||
public IEvent duplicate() throws CloneNotSupportedException {
|
||||
return (IEvent)this.clone();
|
||||
return (IEvent) this.clone();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user