List of usage examples for java.util Vector toArray
@SuppressWarnings("unchecked") public synchronized <T> T[] toArray(T[] a)
From source file:es.emergya.ui.plugins.AdminPanel.java
public MyTableModel(Vector<String> headers, int i) { this(headers.toArray(new String[0]), i); }
From source file:com.w20e.socrates.model.ExpressionCompiler.java
/** * Create the named function.//from w w w .j a v a 2s . co m * * @param arg0 * function name * @param arg1 * arguments * @return the function or false if unknown. */ @Override public Object function(final Object arg0, final Object[] arg1) { //System.out.println("2 " + arg0); //System.out.println(arg1); if (arg0.toString().equals("exp")) { Exp exp = new Exp(); exp.setLeftOperand((Expression) arg1[0]); return exp; } else if (arg0.toString().equals("max")) { Max exp = new Max(); exp.setLeftOperand((Expression) arg1[0]); exp.setRightOperand((Expression) arg1[1]); return exp; } else if (arg0.toString().equals("min")) { Min exp = new Min(); exp.setLeftOperand((Expression) arg1[0]); exp.setRightOperand((Expression) arg1[1]); return exp; } else if (arg0.toString().equals("eval")) { return new Eval(arg1[0].toString()); } else if (arg0.toString().equals("matches")) { Matches exp = new Matches(); exp.setLeftOperand((Expression) arg1[0]); exp.setRightOperand((Expression) arg1[1]); return exp; } else if (arg0.toString().equals("datetime")) { DateTime datetime = new DateTime(); Vector<Expression> v = new Vector<Expression>(); if (arg1 != null) { for (Object arg : arg1) { v.add((Expression) arg); } } datetime.setOperands(v.toArray(new Expression[v.size()])); return datetime; } else if (arg0.toString().equals("test") || arg0.toString().equals("if")) { IfThenElse exp = new IfThenElse(); exp.setLeftOperand((Expression) arg1[0]); exp.setMiddleOperand((Expression) arg1[1]); exp.setRightOperand((Expression) arg1[2]); return exp; } else if (arg0.toString().equals("map")) { Map map = new Map(); Vector<Expression> v = new Vector<Expression>(); for (Object arg : arg1) { v.add((Expression) arg); } map.setOperands(v.toArray(new Expression[v.size()])); return map; } else if (arg0.toString().equals("str")) { Str str = new Str(); str.setLeftOperand((Expression) arg1[0]); return str; } else if (arg0.toString().equals("num")) { Num num = new Num(); num.setLeftOperand((Expression) arg1[0]); return num; } else if (arg0.toString().equals("ceil")) { Ceil ceil = new Ceil(); ceil.setLeftOperand((Expression) arg1[0]); return ceil; } else if (arg0.toString().equals("format")) { Format fmt = new Format(); Vector<Expression> v = new Vector<Expression>(); for (Object arg : arg1) { v.add((Expression) arg); } fmt.setOperands(v.toArray(new Expression[v.size()])); return fmt; } else if (arg0.toString().equals("substr")) { Substr sstr = new Substr(); Vector<Expression> v = new Vector<Expression>(); for (Object arg : arg1) { v.add((Expression) arg); } sstr.setOperands(v.toArray(new Expression[v.size()])); return sstr; } else if (arg0.toString().equals("random")) { RandomInt r = new RandomInt(); Vector<Expression> v = new Vector<Expression>(); for (Object arg : arg1) { v.add((Expression) arg); } r.setOperands(v.toArray(new Expression[v.size()])); return r; } else if (arg0.toString().equals("sample")) { Sample s = new Sample(); Vector<Expression> v = new Vector<Expression>(); for (Object arg : arg1) { v.add((Expression) arg); } s.setOperands(v.toArray(new Expression[v.size()])); return s; } else if (arg0.toString().equals("in")) { In in = new In(); Vector<Expression> v = new Vector<Expression>(); for (Object arg : arg1) { v.add((Expression) arg); } in.setOperands(v.toArray(new Expression[v.size()])); return in; } else if (arg0.toString().equals("get")) { Get get = new Get(); Vector<Expression> v = new Vector<Expression>(); for (Object arg : arg1) { v.add((Expression) arg); } get.setOperands(v.toArray(new Expression[v.size()])); return get; } return new XBoolean(false); }
From source file:com.ricemap.spateDB.mapred.SpatialRecordReader.java
/** * Reads all shapes left in the current block in one shot. * @param shapes//from ww w.j a v a 2s.com * @return * @throws IOException */ protected boolean nextShapes(ArrayWritable shapes) throws IOException { // Prepare a vector that will hold all objects in this Vector<Shape> vshapes = new Vector<Shape>(); try { Shape stockObject = (Shape) shapes.getValueClass().newInstance(); // Reached the end of this split if (getPos() >= end) return false; long initialReadPos = getPos(); long readBytes = 0; // Read all shapes in this block while (vshapes.size() < maxShapesInOneRead && readBytes < maxBytesInOneRead && nextShape(stockObject)) { vshapes.add(stockObject.clone()); readBytes = getPos() - initialReadPos; } // Store them in the return value shapes.set(vshapes.toArray(new Shape[vshapes.size()])); return vshapes.size() > 0; } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (OutOfMemoryError e) { LOG.error("Error reading shapes. Stopped with " + vshapes.size() + " shapes"); throw e; } return false; }
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]; }/* ww w . j a v a2 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.alder.fotobuchconvert.ifolor.IfolorLoader.java
/** * // w w w . j a v a 2 s .c o m * @param page * output page * @param _page * input page * @param pgnum * page number */ private void handlePage(BookPage page, ProjectPage _page, int pgnum) { for (AbstractElement _go : _page.GuiObjects) { log.debug("Loading: element:" + _go); int left = _go.left; int top = _go.top; int width = _go.width; int height = _go.height; int angleDegrees = _go.rotateAngle; // boolean dragable = // in_go.Dragable.evalXPathToString().equals("1"); // IfolorDock dock = s2dock(apImDock.evalXPathToString()); if (_go instanceof Image) { Image _image = (Image) _go; String origFile = _image.OrigFilePath; String previewFile = _image.PreviewFilePath; String sourceFile = _image.SourceFilePath; double cropX = 0, cropY = 0, cropW = 0, cropH = 0; if (_image.VisiblePart != null) { cropX = _image.VisiblePart.left / 100d; cropY = _image.VisiblePart.top / 100d; cropW = _image.VisiblePart.width / 100d; cropH = _image.VisiblePart.height / 100d; } BorderShadow bs = s2border(_image.Border); if (bs == null) bs = new BorderShadow(null, null); ImageCutCoords alpha = s2alpha(_image.AlphaSet); log.trace(String.format(" %d,%d\t%s\t\t%f %f %f %f\t%s %s", left, top, origFile, cropX, cropY, cropW, cropH, bs.border, bs.shadow)); BookPicture pic = new BookPicture(left, top, width, height, angleDegrees, origFile, previewFile, sourceFile, cropX, cropY, cropW, cropH, bs.border, bs.shadow, alpha); page.add(pic); } else if (_go instanceof ColorRectangle) { ColorRectangle _colorRect = (ColorRectangle) _go; Vector<ShapeColor> colors = new Vector<ShapeColor>(); for (org.alder.fotobuchconvert.ifolor.model.Color _color : _colorRect.colors) { String value = _color.value; double pos = _color.position; int a = Integer.parseInt(value.substring(0, 2), 16); int r = Integer.parseInt(value.substring(2, 4), 16); int g = Integer.parseInt(value.substring(4, 6), 16); int b = Integer.parseInt(value.substring(6, 8), 16); colors.add(new ShapeColor(new Color(r, g, b, a), pos)); } BookShape shape = new BookShape(left, top, width, height, angleDegrees, colors.toArray(new ShapeColor[0])); page.add(shape); } else if (_go instanceof Text) { Text _text = (Text) _go; String origFile = _text.OrigFilePath; BookRtfText pic = new BookRtfText(left, top, width, height, angleDegrees, origFile); page.add(pic); // } else if ("MetaFile".equals(type)) { // // keine Ahnung, was das ist. Kommt immer wieder vor } else { throw new RuntimeException("Typ " + _go + " nicht bekannt in XML"); } } // page numbers if (_page.LeftPageNumber != null) handlePageNumber(page, _page, _page.LeftPageNumber, pgnum); if (_page.RightPageNumber != null) handlePageNumber(page, _page, _page.RightPageNumber, pgnum + 1); }
From source file:org.kchine.r.server.RListener.java
public static String[] forbiddenSymbols(String voidStr) { if (_forbiddenSymbols == null) { Vector<String> v = new Vector<String>(); v.addAll(DirectJNI.getInstance().getBootStrapRObjects()); v.add("ls"); v.add("objects"); v.add("q"); v.add("win.graph"); v.add("x11"); v.add("X11"); v.add("dev.off"); v.add("graphics.off"); v.add("dev.set"); v.add("help"); v.add("setwd"); _forbiddenSymbols = (String[]) v.toArray(new String[0]); }/*ww w . j a va 2 s. c o m*/ return _forbiddenSymbols; }
From source file:com.sos.VirtualFileSystem.FTP.SOSVfsFtp.java
/** * return a listing of the files in a directory in long format on * the remote machine//w ww . j a va2s . co m * @param pathname on remote machine * @return a listing of the contents of a directory on the remote machine * @exception Exception * @see #nList() * @see #nList( String ) * @see #dir() */ @Override public SOSFileList dir(final String pathname) { Vector<String> strList = getFilenames(pathname); String[] strT = strList.toArray(new String[strList.size()]); SOSFileList objFileList = new SOSFileList(strT); return objFileList; }
From source file:org.dhatim.cdr.SmooksResourceConfigurationStore.java
/** * Get all the SmooksResourceConfiguration entries registered on this context store * for the specified profile set./*from www . ja va 2 s . c o m*/ * @param profileSet The profile set against which to lookup. * @return All SmooksResourceConfiguration entries targeted at the specified useragent. */ public SmooksResourceConfiguration[] getSmooksResourceConfigurations(ProfileSet profileSet) { Vector allSmooksResourceConfigurationsColl = new Vector(); SmooksResourceConfiguration[] allSmooksResourceConfigurations; // Iterate through each of the loaded SmooksResourceConfigurationLists. for (int i = 0; i < configLists.size(); i++) { SmooksResourceConfigurationList list = configLists.get(i); SmooksResourceConfiguration[] resourceConfigs = list.getTargetConfigurations(profileSet); allSmooksResourceConfigurationsColl.addAll(Arrays.asList(resourceConfigs)); } allSmooksResourceConfigurations = new SmooksResourceConfiguration[allSmooksResourceConfigurationsColl .size()]; allSmooksResourceConfigurationsColl.toArray(allSmooksResourceConfigurations); return allSmooksResourceConfigurations; }
From source file:net.aepik.alasca.core.ldap.Schema.java
/** * Retourne l'ensemble des objets du schema dans l'ordre dans lequel * ils ont t ajout au schma./*from ww w . j a v a 2 s. c o m*/ * @return SchemaObject[] L'ensemble des objets du schema. */ public SchemaObject[] getObjectsInOrder() { Vector<SchemaObject> result = new Vector<SchemaObject>(); for (SchemaObject o : this.getObjectsInOrder(this.getSyntax().getObjectIdentifierType())) { result.add(o); } for (SchemaObject o : this.getObjectsInOrder(this.getSyntax().getAttributeType())) { result.add(o); } for (SchemaObject o : this.getObjectsInOrder(this.getSyntax().getObjectClassType())) { result.add(o); } return result.toArray(new SchemaObject[10]); }
From source file:org.fcrepo.server.access.DefaultAccess.java
private String[] getAdminEmails() { String emailsCSV = convertToCSV(getServer().getParameter("adminEmailList")); Vector<Object> emails = new Vector<Object>(); StringTokenizer st = new StringTokenizer(emailsCSV, ","); while (st.hasMoreElements()) { emails.add(st.nextElement());//from w ww . j a v a 2 s . c om } return emails.toArray(EMPTY_STRING_ARRAY); }