Example usage for java.util Vector clone

List of usage examples for java.util Vector clone

Introduction

In this page you can find the example usage for java.util Vector clone.

Prototype

public synchronized Object clone() 

Source Link

Document

Returns a clone of this vector.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);
    model.addColumn("Col1");
    model.addRow(new Object[] { "r1" });
    model.addRow(new Object[] { "r2" });
    model.addRow(new Object[] { "r3" });

    // Get all the table data
    Vector data = model.getDataVector();
    // Copy the second row
    Vector row = (Vector) data.elementAt(1);
    row = (Vector) row.clone();

    JFrame f = new JFrame();
    f.setSize(300, 300);/*from w  w  w . jav  a 2s.c  o m*/
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    Vector v1 = new Vector();
    v1.add("A");/*  w w w  . j ava  2 s .c  o  m*/
    v1.add("C");
    v1.add("B");
    Vector v2 = (Vector) v1.clone();
    Collections.sort(v2);

    System.out.println(v1);
    System.out.println(v2);
}

From source file:Main.java

public static void main(String[] args) {

    Vector<Integer> vec = new Vector<Integer>(4);
    Vector<Integer> vecclone = new Vector<Integer>(4);

    vec.add(4);//www .  j  av  a  2s  .  com
    vec.add(3);
    vec.add(2);
    vec.add(1);

    System.out.println(vec);

    // let us clone the vector vec
    vecclone = (Vector) vec.clone();

    System.out.println(vecclone);

}

From source file:Main.java

/**
 * Returns an enumeration of the vector list that is not changed by parallel changes to the vector.
 * //from w ww.j a v  a 2s . co m
 * @param
 * @return
 */
public static Enumeration getPersistentEntryEnumeration(Vector vector) {
    return ((Vector) vector.clone()).elements();
}

From source file:com.github.maven_nar.cpptasks.compiler.CommandLineCompiler.java

@Override
protected CompilerConfiguration createConfiguration(final CCTask task, final LinkType linkType,
        final ProcessorDef[] baseDefs, final CompilerDef specificDef, final TargetDef targetPlatform,
        final VersionInfo versionInfo) {

    this.prefix = specificDef.getCompilerPrefix();
    this.objDir = task.getObjdir();
    final Vector<String> args = new Vector<>();
    final CompilerDef[] defaultProviders = new CompilerDef[baseDefs.length + 1];
    for (int i = 0; i < baseDefs.length; i++) {
        defaultProviders[i + 1] = (CompilerDef) baseDefs[i];
    }//w  w  w.  ja  v a  2  s. c o  m
    defaultProviders[0] = specificDef;
    final Vector<CommandLineArgument> cmdArgs = new Vector<>();

    //
    // add command line arguments inherited from <cc> element
    // any "extends" and finally the specific CompilerDef
    CommandLineArgument[] commandArgs;
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        commandArgs = defaultProviders[i].getActiveProcessorArgs();
        for (final CommandLineArgument commandArg : commandArgs) {
            if (commandArg.getLocation() == 0) {
                String arg = commandArg.getValue();
                if (isWindows() && arg.matches(".*[ \"].*")) {
                    // Work around inconsistent quoting by Ant
                    arg = "\"" + arg.replaceAll("[\\\\\"]", "\\\\$0") + "\"";
                }
                args.addElement(arg);
            } else {
                cmdArgs.addElement(commandArg);
            }
        }
    }
    final Vector<ProcessorParam> params = new Vector<>();
    //
    // add command line arguments inherited from <cc> element
    // any "extends" and finally the specific CompilerDef
    ProcessorParam[] paramArray;
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        paramArray = defaultProviders[i].getActiveProcessorParams();
        Collections.addAll(params, paramArray);
    }
    paramArray = params.toArray(new ProcessorParam[params.size()]);

    if (specificDef.isClearDefaultOptions() == false) {
        final boolean multithreaded = specificDef.getMultithreaded(defaultProviders, 1);
        final boolean debug = specificDef.getDebug(baseDefs, 0);
        final boolean exceptions = specificDef.getExceptions(defaultProviders, 1);
        final Boolean rtti = specificDef.getRtti(defaultProviders, 1);
        final OptimizationEnum optimization = specificDef.getOptimization(defaultProviders, 1);
        this.addImpliedArgs(args, debug, multithreaded, exceptions, linkType, rtti, optimization);
    }

    //
    // add all appropriate defines and undefines
    //
    buildDefineArguments(defaultProviders, args);
    final int warnings = specificDef.getWarnings(defaultProviders, 0);
    addWarningSwitch(args, warnings);
    Enumeration<CommandLineArgument> argEnum = cmdArgs.elements();
    int endCount = 0;
    while (argEnum.hasMoreElements()) {
        final CommandLineArgument arg = argEnum.nextElement();
        switch (arg.getLocation()) {
        case 1:
            args.addElement(arg.getValue());
            break;
        case 2:
            endCount++;
            break;
        }
    }
    final String[] endArgs = new String[endCount];
    argEnum = cmdArgs.elements();
    int index = 0;
    while (argEnum.hasMoreElements()) {
        final CommandLineArgument arg = argEnum.nextElement();
        if (arg.getLocation() == 2) {
            endArgs[index++] = arg.getValue();
        }
    }
    //
    // Want to have distinct set of arguments with relative
    // path names for includes that are used to build
    // the configuration identifier
    //
    final Vector<String> relativeArgs = (Vector) args.clone();
    //
    // add all active include and sysincludes
    //
    final StringBuffer includePathIdentifier = new StringBuffer();
    final File baseDir = specificDef.getProject().getBaseDir();
    String baseDirPath;
    try {
        baseDirPath = baseDir.getCanonicalPath();
    } catch (final IOException ex) {
        baseDirPath = baseDir.toString();
    }
    final Vector<String> includePath = new Vector<>();
    final Vector<String> sysIncludePath = new Vector<>();
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        String[] incPath = defaultProviders[i].getActiveIncludePaths();
        for (final String element : incPath) {
            includePath.addElement(element);
        }
        incPath = defaultProviders[i].getActiveSysIncludePaths();
        for (final String element : incPath) {
            sysIncludePath.addElement(element);
        }
    }
    final File[] incPath = new File[includePath.size()];
    for (int i = 0; i < includePath.size(); i++) {
        incPath[i] = new File(includePath.elementAt(i));
    }
    final File[] sysIncPath = new File[sysIncludePath.size()];
    for (int i = 0; i < sysIncludePath.size(); i++) {
        sysIncPath[i] = new File(sysIncludePath.elementAt(i));
    }
    addIncludes(baseDirPath, incPath, args, relativeArgs, includePathIdentifier, false);
    addIncludes(baseDirPath, sysIncPath, args, null, null, true);
    final StringBuffer buf = new StringBuffer(getIdentifier());
    for (int i = 0; i < relativeArgs.size(); i++) {
        buf.append(' ');
        buf.append(relativeArgs.elementAt(i));
    }
    for (final String endArg : endArgs) {
        buf.append(' ');
        buf.append(endArg);
    }
    final String configId = buf.toString();
    final String[] argArray = new String[args.size()];
    args.copyInto(argArray);
    final boolean rebuild = specificDef.getRebuild(baseDefs, 0);
    final File[] envIncludePath = getEnvironmentIncludePath();
    final String path = specificDef.getToolPath();

    CommandLineCompiler compiler = this;
    Environment environment = specificDef.getEnv();
    if (environment == null) {
        for (final ProcessorDef baseDef : baseDefs) {
            environment = baseDef.getEnv();
            if (environment != null) {
                compiler = (CommandLineCompiler) compiler.changeEnvironment(baseDef.isNewEnvironment(),
                        environment);
            }
        }
    } else {
        compiler = (CommandLineCompiler) compiler.changeEnvironment(specificDef.isNewEnvironment(),
                environment);
    }
    return new CommandLineCompilerConfiguration(compiler, configId, incPath, sysIncPath, envIncludePath,
            includePathIdentifier.toString(), argArray, paramArray, rebuild, endArgs, path,
            specificDef.getCcache());
}

From source file:org.apache.slide.store.ExtendedStore.java

public void grantPermission(Uri uri, NodePermission permission) throws ServiceAccessException {
    super.grantPermission(uri, permission);
    if (securityStore.cacheResults()) {
        enlist(this);
        try {/* www .  java2 s.  c o  m*/
            Vector permissionsVector = fillPermissionsCache(uri);
            // operate on a copy
            Vector tempPermissions = (Vector) permissionsVector.clone();
            tempPermissions.addElement(permission);
            permissionsCache.put(uri.toString(), tempPermissions);
        } finally {
            delist(this);
        }
    }
}

From source file:org.apache.slide.store.ExtendedStore.java

public void revokePermission(Uri uri, NodePermission permission) throws ServiceAccessException {
    super.revokePermission(uri, permission);
    if (securityStore.cacheResults()) {
        enlist(this);
        try {/* ww w .  j a  v  a 2  s. c  o m*/
            Vector permissionsVector = fillPermissionsCache(uri);
            // operate on a copy
            Vector tempPermissions = (Vector) permissionsVector.clone();
            tempPermissions.removeElement(permission);
            permissionsCache.put(uri.toString(), tempPermissions);
        } finally {
            delist(this);
        }

    }
}

From source file:org.apache.slide.store.ExtendedStore.java

public Enumeration enumeratePermissions(Uri uri) throws ServiceAccessException {
    if (securityStore.cacheResults()) {
        if (isForceStoreEnlistment(uri)) {
            enlist(this);
        }//from w  ww .  jav a  2 s .  c  om
        try {
            Vector permissionsVector = fillPermissionsCache(uri);
            return ((Vector) permissionsVector.clone()).elements();
        } finally {
            if (isForceStoreEnlistment(uri)) {
                delist(this);
            }
        }
    } else {
        return super.enumeratePermissions(uri);
    }
}

From source file:org.apache.slide.store.ExtendedStore.java

public void putLock(Uri uri, NodeLock lock) throws ServiceAccessException {
    super.putLock(uri, lock);
    if (lockStore.cacheResults()) {
        enlist(this);
        try {/*w ww .j a  v  a  2  s .co m*/
            Vector locks = fillLocksCache(uri);
            // operate on a copy
            Vector tempLocks = (Vector) locks.clone();
            tempLocks.addElement(lock.cloneObject());
            locksCache.put(uri.toString(), tempLocks);
        } finally {
            delist(this);
        }
    }
}

From source file:org.apache.slide.store.ExtendedStore.java

public Enumeration enumerateLocks(Uri uri) throws ServiceAccessException {
    if (lockStore.cacheResults()) {
        if (isForceStoreEnlistment(uri)) {
            enlist(this);
        }//from w  w w .  j  a  v  a2s.c om
        try {
            Vector locks = fillLocksCache(uri);
            return ((Vector) locks.clone()).elements();
        } finally {
            if (isForceStoreEnlistment(uri)) {
                delist(this);
            }
        }
    } else {
        return super.enumerateLocks(uri);
    }
}