List of usage examples for java.lang String clone
@HotSpotIntrinsicCandidate protected native Object clone() throws CloneNotSupportedException;
From source file:com.siberhus.tdfl.transform.DefaultFieldSet.java
public DefaultFieldSet(String values[], String labels[]) { Assert.notNull(values);//from w ww . ja va 2 s . co m Assert.notNull(labels); this.values = (String[]) values.clone(); if (values.length < labels.length) { int addSize = labels.length - values.length; values = (String[]) ArrayUtils.addAll(values, new String[addSize]); } // if (values.length != labels.length) { // throw new IllegalArgumentException("Field labels must be same length as values: labels=" // + Arrays.asList(labels) + ", values=" + Arrays.asList(values)); // } this.labels = Arrays.asList(labels); }
From source file:com.quartercode.femtoweb.api.resolutions.Redirect.java
/** * Creates a new redirect action which redirects the user to the given {@link Action}. * Internally, the user is redirected to the URI the action is mapped to. * See the {@link Action} javadoc for more details on that URI mapping. * * @param action The action the user should be redirected to. * @param parameters An alternating array of GET parameter names and values that should be appended to the URI of the action. * For example, the array {@code [param1, value1, param2, value2]} would result in the URI {@code ...?param1=value1¶m2=value2}. * If this array is empty, nothing (not even {@code ?}) is appended to the URI. *///ww w . j a va 2 s. c om public Redirect(Class<? extends Action> action, String... parameters) { Validate.notNull(action, "Cannot redirect to null action"); Validate.noNullElements(parameters, "Cannot use a null parameter for redirect"); Validate.isTrue(parameters.length % 2 == 0, "Invalid parameter format; parameter names and values must alternate in array"); url = null; this.action = action; this.parameters = parameters.clone(); }
From source file:com.tumanako.dash.DashMessages.java
/** DashMessages Constructor/*from w w w . jav a 2 s. c om*/ @param context Reference to the application context. Used to get an application-specific broadcast manager object. @param callbackParent Reference to the object which will provide the messageReceived method to handle messages. Must refer to an object which implements IDashMessages interface. @param intentActionFilters Array of strings to use as action filters. This DashMessages object will respond to any intent with one of these strings as the "action". */ public DashMessages(Context context, IDashMessages callbackParent, String intentActionFilters[]) { parent = callbackParent; // Get a Broadcast Manager so we can send out messages to other parts of the app, and receive mesages for this class: messageBroadcaster = LocalBroadcastManager.getInstance(context); // Register to receive messages via Intents if a filter was provided: if (intentActionFilters != null) actionFilter = intentActionFilters.clone(); resume(); }
From source file:FilterSample.java
public ExtensionFileFilter(String description, String extensions[]) { if (description == null) { // Since no description, use first extension and # of extensions as // description this.description = extensions[0] + "{" + extensions.length + "}"; } else {/* w w w. j ava 2 s . co m*/ this.description = description; } this.extensions = (String[]) extensions.clone(); // Convert array to lowercase // Don't alter original entries toLower(this.extensions); }
From source file:org.protempa.AbstractPropositionDefinition.java
/** * Assigns this proposition with associated {@link TermDefinition} ids. * * @param termId a term definition id {@link String}. No <code>null</code> * or duplicate elements allowed.//w ww . j a v a 2 s . co m */ public final void setTermIds(String... termIds) { String[] old = this.termIds; ProtempaUtil.checkArrayForNullElement(termIds, "termIds"); ProtempaUtil.checkArrayForDuplicates(termIds, "termIds"); this.termIds = termIds.clone(); if (this.changes != null) { this.changes.firePropertyChange("termIds", old, getTermIds()); } }
From source file:org.protempa.AbstractPropositionDefinition.java
/** * Sets the children of this proposition definition. * * @param inverseIsA a {@link String[]} of proposition definition ids. No * <code>null</code> or duplicate elements allowed. *///w ww .j a v a 2 s.co m public void setInverseIsA(String... inverseIsA) { String[] old = this.inverseIsA; ProtempaUtil.checkArrayForNullElement(inverseIsA, "inverseIsA"); ProtempaUtil.checkArrayForDuplicates(inverseIsA, "inverseIsA"); this.inverseIsA = inverseIsA.clone(); if (this.changes != null) { this.changes.firePropertyChange("inverseIsA", old, getInverseIsA()); } recalculateChildren(); }
From source file:org.apache.hadoop.yarn.sls.SLSRunner.java
public SLSRunner(boolean isSLS, String inputTraces[], String nodeFile, String outputDir, Set<String> trackedApps, boolean printsimulation) throws IOException, ClassNotFoundException { this.isSLS = isSLS; this.inputTraces = inputTraces.clone(); this.nodeFile = nodeFile; this.trackedApps = trackedApps; this.printSimulation = printsimulation; metricsOutputDir = outputDir;// w w w .j ava 2 s .c o m nmMap = new HashMap<NodeId, NMSimulator>(); queueAppNumMap = new HashMap<String, Integer>(); amMap = new HashMap<String, AMSimulator>(); amClassMap = new HashMap<String, Class>(); // runner configuration conf = new Configuration(false); conf.addResource("sls-runner.xml"); // runner int poolSize = conf.getInt(SLSConfiguration.RUNNER_POOL_SIZE, SLSConfiguration.RUNNER_POOL_SIZE_DEFAULT); SLSRunner.runner.setQueueSize(poolSize); // <AMType, Class> map for (Map.Entry e : conf) { String key = e.getKey().toString(); if (key.startsWith(SLSConfiguration.AM_TYPE)) { String amType = key.substring(SLSConfiguration.AM_TYPE.length()); amClassMap.put(amType, Class.forName(conf.get(key))); } } }
From source file:org.eclipse.wb.tests.designer.XML.AbstractXmlObjectTest.java
/** * "Decorates" given lines of XML. By default adds required namespace declarations, see * {@link #getTestSource_namespaces()}.//w w w .jav a 2 s . c o m */ protected final String[] getTestSource_decorate(String... lines) { // try to find line where name spaces should be inserted for (int i = 0; i < lines.length; i++) { String line = lines[i]; if (line.startsWith("<?xml")) { continue; } // prepare position for namespaces int index = StringUtils.indexOfAny(line, " />"); if (index > 0) { if (line.charAt(index - 1) == '-') { continue; } } // insert namespaces into line line = getXMLSource_insertNameSpaces_intoGivenLine(line, index); // modify copy lines = lines.clone(); lines[i] = line; // done break; } return lines; }
From source file:org.simplx.args.MainArgs.java
/** * Add descriptive text for the program itself. This will be included in * the usage message./*from ww w.j a va2 s .com*/ * * @param desc The desriptive text. Each string will be shown on a line of * its own. */ public void programDescription(String... desc) { programDesc = desc.clone(); hasDescs |= desc.length > 0; }
From source file:org.simplx.args.MainArgs.java
/** * Returns the command line operands that come after the options. This * checks to make sure that all specified options have been consumed -- any * options remaining at this point are assumed to be unknown options. If no * operands remain, an empty array is returned. * <p/>/*w ww . ja v a 2s . co m*/ * This is also where {@code -help} is handled. If the user specifies {@code * -help}, and that option is not manually process by the code using {@link * #getBoolean(String, String...)} getBoolean}, then the method {@link * #usage} is invoked and {@link HelpOnlyException} is thrown. The program * is expected to catch this exception and simply exit successfully. * * @param operandsDesc Operand descriptions. In usage messages, this will be * printed out after the options usage is described. * Typically this ends with {@code "..."} if an * arbitrary number of operands can be specified. * * @return The operands that follow the options. * * @throws CommandLineException An unknown option was specified. * @throws HelpOnlyException The user asked for usage/help information. * @see #synopsis() * @see #usage() */ @SuppressWarnings({ "ParameterHidesMemberVariable" }) public String[] getOperands(String... operandsDesc) throws CommandLineException, HelpOnlyException { operandsFetched = true; this.operandsDesc = operandsDesc.clone(); checkForHelp(); StringBuilder unused = new StringBuilder(); int count = 0; int a; for (a = 0; a < args.length; a++) { if (used.get(a)) { // skip used parameters continue; } if (!args[a].startsWith("-")) { // first non-option argument break; } if (args[a].equals("--")) { // "--" ends things a++; // skip the "--" break; } if (unused.length() > 1) { unused.append(' '); } unused.append(args[a]); count++; } if (unused.length() != 0) { String ustr = unused.toString(); String plural = count > 0 ? "s" : ""; String msg = "unknown/unused option" + plural + ": " + ustr; throw new CommandLineException(msg); } String[] remains = new String[args.length - a]; System.arraycopy(args, a, remains, 0, remains.length); return remains; }