本文整理汇总了Java中java.util.Vector.addElement方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.addElement方法的具体用法?Java Vector.addElement怎么用?Java Vector.addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Vector
的用法示例。
在下文中一共展示了Vector.addElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateOcts
import java.util.Vector; //导入方法依赖的package包/类
private Vector generateOcts()
{
Vector vec = new Vector();
for (int i = 0; i < string.length; i += MAX_LENGTH)
{
int end;
if (i + MAX_LENGTH > string.length)
{
end = string.length;
}
else
{
end = i + MAX_LENGTH;
}
byte[] nStr = new byte[end - i];
System.arraycopy(string, i, nStr, 0, nStr.length);
vec.addElement(new DEROctetString(nStr));
}
return vec;
}
示例2: getCleanMessages
import java.util.Vector; //导入方法依赖的package包/类
public static Vector getCleanMessages(Vector messages, String messageId)
throws ProtocolException {
if (messages == null || messageId == null) {
return messages;
}
Vector cleanMessages = new Vector();
Enumeration en = messages.elements();
while (en.hasMoreElements()) {
String msg = (String) en.nextElement();
MessageHeader hd = new MessageHeader(msg);
if (messageId.equals(hd.getMessageId())) {
cleanMessages.addElement(msg);
}
}
return cleanMessages;
}
示例3: testFirstAndNext
import java.util.Vector; //导入方法依赖的package包/类
private Vector testFirstAndNext(BreakIterator bi, String text) {
int p = bi.first();
int lastP = p;
Vector<String> result = new Vector<String>();
if (p != 0)
errln("first() returned " + p + " instead of 0");
while (p != BreakIterator.DONE) {
p = bi.next();
if (p != BreakIterator.DONE) {
if (p <= lastP)
errln("next() failed to move forward: next() on position "
+ lastP + " yielded " + p);
result.addElement(text.substring(lastP, p));
}
else {
if (lastP != text.length())
errln("next() returned DONE prematurely: offset was "
+ lastP + " instead of " + text.length());
}
lastP = p;
}
return result;
}
示例4: getTargetFormats
import java.util.Vector; //导入方法依赖的package包/类
/**
*/
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
// filter out targetEncoding from the old getOutputFormats( sourceFormat ) method
AudioFormat[] formats = getOutputFormats( sourceFormat );
Vector newFormats = new Vector();
for(int i=0; i<formats.length; i++ ) {
if( formats[i].getEncoding().equals( targetEncoding ) ) {
newFormats.addElement( formats[i] );
}
}
AudioFormat[] formatArray = new AudioFormat[newFormats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(newFormats.elementAt(i));
}
return formatArray;
}
示例5: addFun
import java.util.Vector; //导入方法依赖的package包/类
private static void addFun(String name, String cspec,
Vector sha3classes)
{
int n = cspec.indexOf(',');
if (n < 0) {
NAME_TO_CLASSNAMES.put(name, cspec);
ORDERED_CLASSNAMES.addElement(cspec);
} else {
String base = cspec.substring(0, n);
NAME_TO_CLASSNAMES.put(name + "224", base + "224");
ORDERED_CLASSNAMES.addElement(base + "224");
NAME_TO_CLASSNAMES.put(name + "256", base + "256");
ORDERED_CLASSNAMES.addElement(base + "256");
NAME_TO_CLASSNAMES.put(name + "384", base + "384");
ORDERED_CLASSNAMES.addElement(base + "384");
NAME_TO_CLASSNAMES.put(name + "512", base + "512");
ORDERED_CLASSNAMES.addElement(base + "512");
int len = cspec.length();
StringBuffer sb = new StringBuffer();
n ++;
while (n < len) {
int p = cspec.indexOf(',', n);
if (p < 0)
p = len;
String suffix = cspec.substring(n, p);
if (sb.length() > 0)
sb.append(',');
String cname = base + suffix;
sb.append(cname);
if (sha3classes != null)
sha3classes.addElement(cname);
n = p + 1;
}
String ac = sb.toString();
NAME_TO_CLASSNAMES.put(name, ac);
}
}
示例6: addSubclassInstances
import java.util.Vector; //导入方法依赖的package包/类
private void addSubclassInstances(Vector<JavaHeapObject> v) {
for (int i = 0; i < subclasses.length; i++) {
subclasses[i].addSubclassInstances(v);
}
for (int i = 0; i < instances.size(); i++) {
v.addElement(instances.elementAt(i));
}
}
示例7: getArguments
import java.util.Vector; //导入方法依赖的package包/类
/**
* Get arguments
*/
public Vector getArguments() {
if (isConstructor() && (getClassDefinition().getSuperClass() == null)) {
Vector v = new Vector();
v.addElement(new LocalMember(0, getClassDefinition(), 0,
getClassDefinition().getType(), idThis));
return v;
}
return null;
}
示例8: ConjQuery
import java.util.Vector; //导入方法依赖的package包/类
final public QueryNode ConjQuery(CharSequence field) throws ParseException {
QueryNode first, c;
Vector<QueryNode> clauses = null;
first = ModClause(field);
label_3:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case AND:
;
break;
default:
jj_la1[6] = jj_gen;
break label_3;
}
jj_consume_token(AND);
c = ModClause(field);
if (clauses == null) {
clauses = new Vector<>();
clauses.addElement(first);
}
clauses.addElement(c);
}
if (clauses != null) {
{if (true) return new AndQueryNode(clauses);}
} else {
{if (true) return first;}
}
throw new Error("Missing return statement in function");
}
示例9: getAllTables
import java.util.Vector; //导入方法依赖的package包/类
private Vector getAllTables() {
Vector result = new Vector(20);
try {
if (cConn == null) {
return null;
}
dbmeta = cConn.getMetaData();
String[] tableTypes = { "TABLE" };
ResultSet allTables = dbmeta.getTables(null, null, null,
tableTypes);
while (allTables.next()) {
String aktTable = allTables.getString("TABLE_NAME");
ResultSet primKeys = dbmeta.getPrimaryKeys(null, null,
aktTable);
// take only table with a primary key
if (primKeys.next()) {
result.addElement(aktTable);
}
primKeys.close();
}
allTables.close();
} catch (SQLException e) {
// System.out.println("SQL Exception: " + e.getMessage());
}
return result;
}
示例10: contextReturn
import java.util.Vector; //导入方法依赖的package包/类
public void contextReturn(Algorithm alg)
{
Vector<Command> oldCommands = commandsStack.pop();
oldCommands.addElement(alg);
commands = oldCommands;
currentCommand = commands.size() - 1;
}
示例11: addReference
import java.util.Vector; //导入方法依赖的package包/类
/**
* Adds a further ontoReference as start argument to the vector of start arguments.
*
* @param agentReference the agent reference
* @param ontoReference the onto reference
* @return the index position of the new element
*/
public int addReference(String agentReference, String ontoReference) {
if (ontoReference==null) return -1;
Vector<AgentStartArgument> argumentVector = this.get(agentReference);
if (argumentVector==null) {
argumentVector = new Vector<AgentStartArgument>();
this.put(agentReference, argumentVector);
}
AgentStartArgument agentStartArgument = new AgentStartArgument(argumentVector.size()+1, ontoReference);
argumentVector.addElement(agentStartArgument);
return argumentVector.size()-1;
}
示例12: addGateListener
import java.util.Vector; //导入方法依赖的package包/类
@Override
public synchronized void addGateListener(GateListener l) {
@SuppressWarnings("unchecked")
Vector<GateListener> v = gateListeners == null ? new Vector<GateListener>(2) : (Vector<GateListener>)gateListeners
.clone();
if(!v.contains(l)) {
v.addElement(l);
gateListeners = v;
}
}
示例13: getDOMImplementationList
import java.util.Vector; //导入方法依赖的package包/类
/**
* Return a list of implementations that support the
* desired features.
*
* @param features
* A string that specifies which features are required. This is
* a space separated list in which each feature is specified by
* its name optionally followed by a space and a version number.
* This is something like: "XML 1.0 Traversal +Events 2.0"
* @return A list of DOMImplementations that support the desired features.
*/
public DOMImplementationList getDOMImplementationList(final String features) {
final Vector implementations = new Vector();
int size = sources.size();
for (int i = 0; i < size; i++) {
DOMImplementationSource source =
(DOMImplementationSource) sources.elementAt(i);
DOMImplementationList impls =
source.getDOMImplementationList(features);
for (int j = 0; j < impls.getLength(); j++) {
DOMImplementation impl = impls.item(j);
implementations.addElement(impl);
}
}
return new DOMImplementationList() {
public DOMImplementation item(final int index) {
if (index >= 0 && index < implementations.size()) {
try {
return (DOMImplementation)
implementations.elementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
}
return null;
}
public int getLength() {
return implementations.size();
}
};
}
示例14: insert
import java.util.Vector; //导入方法依赖的package包/类
/**
* Inserts the specified component into the menu at a given
* position.
*
* @param component the <code>Component</code> to insert
* @param index specifies the position at which
* to insert the component, where 0 is the first
* @exception IllegalArgumentException if <code>index</code> < 0
*/
public void insert(Component component, int index) {
if (index < 0) {
throw new IllegalArgumentException("index less than zero.");
}
int nitems = getComponentCount();
// PENDING(ges): Why not use an array?
Vector<Component> tempItems = new Vector<Component>();
/* Remove the item at index, nitems-index times
storing them in a temporary vector in the
order they appear on the menu.
*/
for (int i = index ; i < nitems; i++) {
tempItems.addElement(getComponent(index));
remove(index);
}
add(component);
/* Add the removed items back to the menu, they are
already in the correct order in the temp vector.
*/
for (Component tempItem : tempItems) {
add(tempItem);
}
}
示例15: testSpeed
import java.util.Vector; //导入方法依赖的package包/类
public void testSpeed() {
randomGenerator = new Random(System.currentTimeMillis());
int TEST_RUNS = 100000;
int LOOP_COUNT = 1000;
HsqlArrayList arrayList = new HsqlArrayList(TEST_RUNS);
ArrayList utilArrayList = new ArrayList(TEST_RUNS);
Vector vector = new Vector(TEST_RUNS);
Integer value = new Integer(randomGenerator.nextInt());
Integer INT_0 = new Integer(0);
StopWatch sw = new StopWatch();
System.out.println(sw.currentElapsedTimeToMessage("time"));
for (int i = 0; i < TEST_RUNS; i++) {
arrayList.add(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
arrayList.set(i, INT_0);
}
}
System.out.println(
sw.currentElapsedTimeToMessage("time HsqlArrayLsit"));
sw.zero();
for (int i = 0; i < TEST_RUNS; i++) {
utilArrayList.add(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
utilArrayList.set(i, INT_0);
}
}
System.out.println(sw.currentElapsedTimeToMessage("time ArrayList"));
sw.zero();
for (int i = 0; i < TEST_RUNS; i++) {
vector.addElement(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
vector.setElementAt(INT_0, i);
}
}
System.out.println(sw.currentElapsedTimeToMessage("time Vector"));
}