ICU-8167 mark protected non-APIs as @internal

X-SVN-Rev: 29547
This commit is contained in:
Markus Scherer 2011-03-05 00:12:34 +00:00
parent b55bbd25a9
commit b05089cd04
3 changed files with 134 additions and 0 deletions

View File

@ -122,10 +122,26 @@ public final class BytesTrieBuilder extends StringTrieBuilder {
return this;
}
/**
* {@inheritDoc}
*/
@Override
protected boolean matchNodesCanHaveValues() /*const*/ { return false; }
/**
* {@inheritDoc}
*/
@Override
protected int getMaxBranchLinearSubNodeLength() /*const*/ { return BytesTrie.kMaxBranchLinearSubNodeLength; }
/**
* {@inheritDoc}
*/
@Override
protected int getMinLinearMatch() /*const*/ { return BytesTrie.kMinLinearMatch; }
/**
* {@inheritDoc}
*/
@Override
protected int getMaxLinearMatchLength() /*const*/ { return BytesTrie.kMaxLinearMatchLength; }
private void ensureCapacity(int length) {
@ -140,6 +156,10 @@ public final class BytesTrieBuilder extends StringTrieBuilder {
bytes=newBytes;
}
}
/**
* {@inheritDoc}
*/
@Override
protected int write(int b) {
int newLength=bytesLength+1;
ensureCapacity(newLength);
@ -147,6 +167,10 @@ public final class BytesTrieBuilder extends StringTrieBuilder {
bytes[bytes.length-bytesLength]=(byte)b;
return bytesLength;
}
/**
* {@inheritDoc}
*/
@Override
protected int write(int offset, int length) {
int newLength=bytesLength+length;
ensureCapacity(newLength);
@ -169,6 +193,10 @@ public final class BytesTrieBuilder extends StringTrieBuilder {
// For writeValueAndFinal() and writeDeltaTo().
private final byte[] intBytes=new byte[5];
/**
* {@inheritDoc}
*/
@Override
protected int writeValueAndFinal(int i, boolean isFinal) {
if(0<=i && i<=BytesTrie.kMaxOneByteValue) {
return write(((BytesTrie.kMinOneByteValueLead+i)<<1)|(isFinal?1:0));
@ -201,6 +229,10 @@ public final class BytesTrieBuilder extends StringTrieBuilder {
intBytes[0]=(byte)((intBytes[0]<<1)|(isFinal?1:0));
return write(intBytes, length);
}
/**
* {@inheritDoc}
*/
@Override
protected int writeValueAndType(boolean hasValue, int value, int node) {
int offset=write(node);
if(hasValue) {
@ -208,6 +240,10 @@ public final class BytesTrieBuilder extends StringTrieBuilder {
}
return offset;
}
/**
* {@inheritDoc}
*/
@Override
protected int writeDeltaTo(int jumpTarget) {
int i=bytesLength-jumpTarget;
assert(i>=0);

View File

@ -100,10 +100,26 @@ public final class CharsTrieBuilder extends StringTrieBuilder {
return this;
}
/**
* {@inheritDoc}
*/
@Override
protected boolean matchNodesCanHaveValues() /*const*/ { return true; }
/**
* {@inheritDoc}
*/
@Override
protected int getMaxBranchLinearSubNodeLength() /*const*/ { return CharsTrie.kMaxBranchLinearSubNodeLength; }
/**
* {@inheritDoc}
*/
@Override
protected int getMinLinearMatch() /*const*/ { return CharsTrie.kMinLinearMatch; }
/**
* {@inheritDoc}
*/
@Override
protected int getMaxLinearMatchLength() /*const*/ { return CharsTrie.kMaxLinearMatchLength; }
private void ensureCapacity(int length) {
@ -118,6 +134,10 @@ public final class CharsTrieBuilder extends StringTrieBuilder {
chars=newChars;
}
}
/**
* {@inheritDoc}
*/
@Override
protected int write(int unit) {
int newLength=charsLength+1;
ensureCapacity(newLength);
@ -125,6 +145,10 @@ public final class CharsTrieBuilder extends StringTrieBuilder {
chars[chars.length-charsLength]=(char)unit;
return charsLength;
}
/**
* {@inheritDoc}
*/
@Override
protected int write(int offset, int length) {
int newLength=charsLength+length;
ensureCapacity(newLength);
@ -147,6 +171,10 @@ public final class CharsTrieBuilder extends StringTrieBuilder {
// For writeValueAndFinal(), writeValueAndType() and writeDeltaTo().
private final char[] intUnits=new char[3];
/**
* {@inheritDoc}
*/
@Override
protected int writeValueAndFinal(int i, boolean isFinal) {
if(0<=i && i<=CharsTrie.kMaxOneUnitValue) {
return write(i|(isFinal ? CharsTrie.kValueIsFinal : 0));
@ -168,6 +196,10 @@ public final class CharsTrieBuilder extends StringTrieBuilder {
intUnits[0]=(char)(intUnits[0]|(isFinal ? CharsTrie.kValueIsFinal : 0));
return write(intUnits, length);
}
/**
* {@inheritDoc}
*/
@Override
protected int writeValueAndType(boolean hasValue, int value, int node) {
if(!hasValue) {
return write(node);
@ -189,6 +221,10 @@ public final class CharsTrieBuilder extends StringTrieBuilder {
intUnits[0]|=(char)node;
return write(intUnits, length);
}
/**
* {@inheritDoc}
*/
@Override
protected int writeDeltaTo(int jumpTarget) {
int i=charsLength-jumpTarget;
assert(i>=0);

View File

@ -22,10 +22,14 @@ import java.util.HashMap;
public abstract class StringTrieBuilder {
/**
* Build options for BytesTrieBuilder and CharsTrieBuilder.
* @draft ICU 4.8
* @provisional This API might change or be removed in a future release.
*/
public enum Option {
/**
* Builds a trie quickly.
* @draft ICU 4.8
* @provisional This API might change or be removed in a future release.
*/
FAST,
/**
@ -36,12 +40,22 @@ public abstract class StringTrieBuilder {
* <p>This option can be effective when many integer values are the same
* and string/byte sequence suffixes can be shared.
* Runtime speed is not expected to improve.
* @draft ICU 4.8
* @provisional This API might change or be removed in a future release.
*/
SMALL
}
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected StringTrieBuilder() {}
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected void addImpl(CharSequence s, int value) {
if(state!=State.ADDING) {
// Cannot add elements after building.
@ -58,6 +72,10 @@ public abstract class StringTrieBuilder {
}
}
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected final void buildImpl(Option buildOption) {
switch(state) {
case ADDING:
@ -98,6 +116,10 @@ public abstract class StringTrieBuilder {
state=State.BUILT;
}
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected void clearImpl() {
strings.setLength(0);
nodes.clear();
@ -782,16 +804,52 @@ public abstract class StringTrieBuilder {
return node;
}
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract boolean matchNodesCanHaveValues() /*const*/;
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract int getMaxBranchLinearSubNodeLength() /*const*/;
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract int getMinLinearMatch() /*const*/;
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract int getMaxLinearMatchLength() /*const*/;
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract int write(int unit);
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract int write(int offset, int length);
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract int writeValueAndFinal(int i, boolean isFinal);
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract int writeValueAndType(boolean hasValue, int value, int node);
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected abstract int writeDeltaTo(int jumpTarget);
private enum State {
@ -800,6 +858,10 @@ public abstract class StringTrieBuilder {
private State state=State.ADDING;
// Strings and sub-strings for linear-match nodes.
/**
* @internal
* @deprecated This API is ICU internal only.
*/
protected StringBuilder strings=new StringBuilder();
private Node root;