If you think the Android project spades listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/**
* Copyright (C) 2013 Pau Picas Sans <pau.picas@gmail.com>
*//fromwww.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/package cat.picas.spades;
import java.util.Arrays;
publicclass CursorInfoBuilder {
privatefinal Tables mTables = Tables.getInstance();
privateint mOffset = 0;
privateboolean[] mHasTables;
privateint[][] mColumnIndexes;
public CursorInfoBuilder() {
mHasTables = newboolean[mTables.size()];
Arrays.fill(mHasTables, false);
mColumnIndexes = newint[mTables.size()][];
for (Table table : mTables.getTables()) {
mColumnIndexes[table.index] = newint[table.getColumnsSize()];
Arrays.fill(mColumnIndexes[table.index], CursorInfo.INVALID_INDEX);
}
}
public CursorInfoBuilder addOffset() {
mOffset++;
returnthis;
}
public CursorInfoBuilder addOffset(int inc) {
mOffset += inc;
returnthis;
}
public CursorInfoBuilder add(Table table) {
add(table.getColumns());
returnthis;
}
public CursorInfoBuilder add(Column column) {
Table table = column.getTable();
if (mColumnIndexes[table.index][column.index] == CursorInfo.INVALID_INDEX) {
mHasTables[table.index] = true;
mColumnIndexes[table.index][column.index] = mOffset++;
}
returnthis;
}
public CursorInfoBuilder add(Iterable<? extends Column> columns) {
for (Column column : columns) {
add(column);
}
returnthis;
}
public CursorInfoBuilder add(Column... columns) {
for (Column column : columns) {
add(column);
}
returnthis;
}
public CursorInfo build() {
returnnew CursorInfo(mHasTables, mColumnIndexes);
}
}