List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY
String[] EMPTY_STRING_ARRAY
To view the source code for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.
Click Source Link
String
array. From source file:com.opengamma.financial.analytics.model.pnl.YieldCurveNodePnLFunction.java
@Override public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) { final Position position = target.getPosition(); final ConfigSource configSource = OpenGammaExecutionContext.getConfigSource(executionContext); final Clock snapshotClock = executionContext.getValuationClock(); final LocalDate now = snapshotClock.zonedDateTime().toLocalDate(); final Currency currency = FinancialSecurityUtils.getCurrency(position.getSecurity()); final String currencyString = currency.getCode(); final ValueRequirement desiredValue = desiredValues.iterator().next(); final ValueProperties constraints = desiredValue.getConstraints(); final String curveCalculationConfigName = desiredValue .getConstraint(ValuePropertyNames.CURVE_CALCULATION_CONFIG); final Set<String> yieldCurveNames = constraints.getValues(ValuePropertyNames.CURVE); final Period samplingPeriod = getSamplingPeriod( desiredValue.getConstraint(ValuePropertyNames.SAMPLING_PERIOD)); final LocalDate startDate = now.minus(samplingPeriod); final Schedule scheduleCalculator = getScheduleCalculator( desiredValue.getConstraint(ValuePropertyNames.SCHEDULE_CALCULATOR)); final TimeSeriesSamplingFunction samplingFunction = getSamplingFunction( desiredValue.getConstraint(ValuePropertyNames.SAMPLING_FUNCTION)); final LocalDate[] schedule = HOLIDAY_REMOVER .getStrippedSchedule(scheduleCalculator.getSchedule(startDate, now, true, false), WEEKEND_CALENDAR); //REVIEW emcleod should "fromEnd" be hard-coded? DoubleTimeSeries<?> result = null; final ConfigDBCurveCalculationConfigSource curveCalculationConfigSource = new ConfigDBCurveCalculationConfigSource( configSource);//from ww w . ja va2s.co m final MultiCurveCalculationConfig curveCalculationConfig = curveCalculationConfigSource .getConfig(curveCalculationConfigName); for (final String yieldCurveName : yieldCurveNames) { final ValueRequirement ycnsRequirement = getYCNSRequirement(currencyString, curveCalculationConfigName, yieldCurveName, target, constraints); final Object ycnsObject = inputs.getValue(ycnsRequirement); if (ycnsObject == null) { throw new OpenGammaRuntimeException( "Could not get yield curve node sensitivities; " + ycnsRequirement); } final DoubleLabelledMatrix1D ycns = (DoubleLabelledMatrix1D) ycnsObject; final ValueRequirement ychtsRequirement = getYCHTSRequirement(currency, yieldCurveName, samplingPeriod.toString()); final Object ychtsObject = inputs.getValue(ychtsRequirement); if (ychtsObject == null) { throw new OpenGammaRuntimeException( "Could not get yield curve historical time series; " + ychtsRequirement); } final HistoricalTimeSeriesBundle ychts = (HistoricalTimeSeriesBundle) ychtsObject; final DoubleTimeSeries<?> pnLSeries; if (curveCalculationConfig.getCalculationMethod().equals(FXImpliedYieldCurveFunction.FX_IMPLIED)) { pnLSeries = getPnLSeries(ycns, ychts, schedule, samplingFunction); } else { final ValueRequirement curveSpecRequirement = getCurveSpecRequirement(currency, yieldCurveName); final Object curveSpecObject = inputs.getValue(curveSpecRequirement); if (curveSpecObject == null) { throw new OpenGammaRuntimeException( "Could not get curve specification; " + curveSpecRequirement); } final InterpolatedYieldCurveSpecificationWithSecurities curveSpec = (InterpolatedYieldCurveSpecificationWithSecurities) curveSpecObject; pnLSeries = getPnLSeries(curveSpec, ycns, ychts, schedule, samplingFunction); } if (result == null) { result = pnLSeries; } else { result = result.add(pnLSeries); } } if (result == null) { throw new OpenGammaRuntimeException("Could not get any values for security " + position.getSecurity()); } result = result.multiply(position.getQuantity().doubleValue()); final ValueProperties resultProperties = getResultProperties(desiredValue, currencyString, yieldCurveNames.toArray(ArrayUtils.EMPTY_STRING_ARRAY), curveCalculationConfigName); final ValueSpecification resultSpec = new ValueSpecification(ValueRequirementNames.PNL_SERIES, target.toSpecification(), resultProperties); return Sets.newHashSet(new ComputedValue(resultSpec, result)); }
From source file:de.iteratec.iteraplan.businesslogic.reports.query.type.Type.java
/** * This method is called to see if the property that is being queried is inheritable or special * and if it is, how the query must be extended to include instances that possibly inherit the * property value. In order to extend the query it is necessary to know the operand and the * undefined value for this property. <br> * Example: For an inheritable date field the operand would be "is" and the undefined value would * be "null".// w ww.j ava 2s . c o m * * @param property * The property of this Type that is possibly inheritable or somehow special. * @return If the property is not special, this method returns a zero length immutable array. * Otherwise a String array of size 2 is returned that contains the operand and the * undefined value for this property. */ public String[] getSpecialPropertyHQL(String property) { if (specialPropertyHQLStrings.containsKey(property)) { return specialPropertyHQLStrings.get(property); } return ArrayUtils.EMPTY_STRING_ARRAY; }
From source file:gov.nih.nci.caarray.util.CaArrayUtilsTest.java
@Test public void testSplitValues() { assertTrue(/* www.jav a 2s . co m*/ Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, CaArrayUtils.splitIntoBooleans(EMPTY_STRING, " "))); assertTrue(Arrays.equals(new boolean[] { true }, CaArrayUtils.splitIntoBooleans("true", ","))); assertTrue(Arrays.equals(new boolean[] { true, false, true }, CaArrayUtils.splitIntoBooleans("true;false;true", ";"))); assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, CaArrayUtils.splitIntoShorts(EMPTY_STRING, " "))); assertTrue(Arrays.equals(new short[] { 0 }, CaArrayUtils.splitIntoShorts("0", ","))); assertTrue(Arrays.equals(new short[] { 3, 1, 2 }, CaArrayUtils.splitIntoShorts("3;1;2", ";"))); assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, CaArrayUtils.splitIntoLongs(EMPTY_STRING, " "))); assertTrue(Arrays.equals(new long[] { 5L }, CaArrayUtils.splitIntoLongs("5", ","))); assertTrue(Arrays.equals(new long[] { 15L, 19L, 13L }, CaArrayUtils.splitIntoLongs("15/19/13", "/"))); assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, CaArrayUtils.splitIntoInts(EMPTY_STRING, " "))); assertTrue(Arrays.equals(new int[] { 1001 }, CaArrayUtils.splitIntoInts("1001", ","))); assertTrue(Arrays.equals(new int[] { -1, 0, -2 }, CaArrayUtils.splitIntoInts("-1 0 -2", " "))); assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, CaArrayUtils.splitIntoFloats(EMPTY_STRING, " "))); assertTrue(Arrays.equals(new float[] { 1.65f }, CaArrayUtils.splitIntoFloats("1.65", ","))); assertTrue(Arrays.equals(new float[] { 0f, 0.33f, -3.76f }, CaArrayUtils.splitIntoFloats("0 0.33 -3.76", " "))); assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, CaArrayUtils.splitIntoDoubles(EMPTY_STRING, " "))); assertTrue(Arrays.equals(new double[] { 1.0 / 3.0 }, CaArrayUtils.splitIntoDoubles("0.3333333333333333", ","))); assertTrue(Arrays.equals(new double[] { 0, -5.0 / 7.0, 11.0 / 13.0 }, CaArrayUtils.splitIntoDoubles("0.0;-0.7142857142857143;0.8461538461538461", ";"))); assertTrue(Arrays.equals(ArrayUtils.EMPTY_STRING_ARRAY, CaArrayUtils.splitFromCsv(EMPTY_STRING))); assertTrue(Arrays.equals(new String[] { "Iam,Dan" }, CaArrayUtils.splitFromCsv("Iam\\,Dan"))); assertTrue(Arrays.equals(new String[] { "I", "m,e", "mi ne" }, CaArrayUtils.splitFromCsv("I,m\\,e,mi ne"))); }
From source file:loci.formats.in.MetamorphReader.java
@Override public String[] getSeriesUsedFiles(boolean noPixels) { FormatTools.assertId(currentId, true, 1); if (!noPixels && stks == null) return new String[] { currentId }; else if (stks == null) return ArrayUtils.EMPTY_STRING_ARRAY; final List<String> v = new ArrayList<String>(); if (ndFilename != null) v.add(ndFilename);/*from w ww . j ava2 s . c om*/ if (!noPixels) { for (String stk : stks[getSeries()]) { if (stk != null && new Location(stk).exists()) { v.add(stk); } } } return v.toArray(new String[v.size()]); }
From source file:com.cyclopsgroup.waterview.Attributes.java
/** * Get string array//from ww w. ja v a 2 s .c om * * @param name Name of the attribute * @param defaultValue Default string value * @return String array */ public String[] getStrings(String name, String defaultValue) { try { String[] values = doGetValues(name); for (int i = 0; i < values.length; i++) { String value = values[i]; if (value == null) { values[i] = defaultValue; } } return values; } catch (Exception e) { return ArrayUtils.EMPTY_STRING_ARRAY; } }
From source file:edu.cornell.med.icb.util.ICBStringUtils.java
/** * Split a string. Optionally respects escape characters. * If multiple splitChars are encountered they will not * be eaten so if splitting on ":" and "\" is the * escape character ":a:::b:c:\::d:" will split to * the String array {"", "a", "", "", "b", "c", ":", "d", ""}. * If splitChar and escapeChar are both the same char, * escapeChar will be ignored.//from www .j a v a 2s .c o m * @param inval string to split. * @param splitChar character to split the string at * @param escapeChar the optional escape character so the splitChar * can be escaped and the string will not be split at that position * @return array of strings, split */ public static String[] split(final String inval, final char splitChar, final Character escapeChar) { if (inval == null) { return null; } if (inval.length() == 0) { return ArrayUtils.EMPTY_STRING_ARRAY; } Character escape = escapeChar; if (escape != null && escape == splitChar) { // Escape and splitChar set to same character // Disable the escaping escape = null; } final List<String> output = new LinkedList<String>(); final int length = inval.length(); final StringBuilder curSplit = new StringBuilder(); boolean inEscape = false; for (int i = 0; i < length; i++) { final char curChar = inval.charAt(i); if (!inEscape && curChar == splitChar) { output.add(curSplit.toString()); curSplit.setLength(0); continue; } if (escape != null) { if (!inEscape && curChar == escape) { // Going into escape. Don't save the // current (escape) character. inEscape = true; curSplit.append(curChar); continue; } if (inEscape) { inEscape = false; } } curSplit.append(curChar); } output.add(curSplit.toString()); return output.toArray(new String[output.size()]); }
From source file:com.adobe.acs.commons.replication.status.impl.JcrPackageReplicationStatusEventHandler.java
/** * Extracts relevant event information from a Granite Replication Event OR a Day CQ Replication event. * @param event the Osgi Event/*from w w w.j ava2 s. c om*/ * @return a Map containing the relevant data points. */ protected final Map<String, Object> getInfoFromEvent(Event event) { final Map<String, Object> eventConfig = new HashMap<>(); final ReplicationEvent replicationEvent = ReplicationEvent.fromEvent(event); if (replicationEvent != null) { // Granite event final ReplicationAction replicationAction = replicationEvent.getReplicationAction(); eventConfig.put(PROPERTY_PATHS, replicationAction.getPaths()); eventConfig.put(PROPERTY_REPLICATED_BY, replicationAction.getUserId()); } else { // CQ event String[] paths = (String[]) event.getProperty(ReplicationAction.PROPERTY_PATHS); if (paths == null) { paths = ArrayUtils.EMPTY_STRING_ARRAY; } String userId = (String) event.getProperty(ReplicationAction.PROPERTY_USER_ID); if (StringUtils.isBlank(userId)) { userId = StringUtils.defaultIfEmpty(this.replicatedByOverride, FALLBACK_REPLICATION_USER_ID); } eventConfig.put(PROPERTY_PATHS, paths); eventConfig.put(PROPERTY_REPLICATED_BY, userId); } return eventConfig; }
From source file:at.ac.tuwien.infosys.jcloudscale.utility.ReflectionUtil.java
/** * Returns the full-qualified class names for the given classes.<br/> * This method is the inverse of {@link #getClassesFromNames(String[], ClassLoader)}. * * @param classes the classes/* w w w. j a va 2 s .c o m*/ * @return a non-null array of the full-qualified class names */ public static String[] getNamesFromClasses(Class<?>... classes) { if (ArrayUtils.isEmpty(classes)) { return ArrayUtils.EMPTY_STRING_ARRAY; } String[] names = new String[classes.length]; for (int i = 0; i < classes.length; i++) { if (classes[i] != null) { names[i] = classes[i].getName(); } } return names; }
From source file:gov.nih.nci.caarray.util.CaArrayUtils.java
/** * <p>/*from w w w. j a va2 s.c om*/ * Splits the provided CSV String into an array of parsed values. * </p> * * Each value within the String will be unescaped by converting any backslash-comma combinations back to commas. * * @param s string containing a comma-separated list of strings. * @return the array of parsed Strings. If s did not contain any comma separated Strings, an empty String. If s was * not a valid CSV string, an IllegalArgumentException is thrown. */ public static String[] splitFromCsv(String s) { try { final CsvReader csvReader = new CsvReader(new StringReader(s), ','); csvReader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH); csvReader.setUseTextQualifier(false); String[] values = ArrayUtils.EMPTY_STRING_ARRAY; if (csvReader.readRecord()) { final int length = csvReader.getColumnCount(); values = new String[length]; for (int i = 0; i < length; i++) { values[i] = csvReader.get(i); } } csvReader.close(); return values; } catch (final IOException e) { throw new IllegalArgumentException("Could not parse as CSV record: " + s, e); } }
From source file:gov.nih.nci.caarray.security.SecurityUtils.java
private static void handleProjectSecurity(Group targetGroup, Project project, SecurityLevel securityLevel) { final ProtectionGroup pg = getProtectionGroup(project); final List<String> roleIds = new ArrayList<String>(); if (securityLevel != SecurityLevel.NONE && securityLevel != SecurityLevel.NO_VISIBILITY) { roleIds.add(getRoleByName(BROWSE_ROLE).getId().toString()); }/*from w ww . j a v a2s . co m*/ if (securityLevel.isAllowsRead()) { roleIds.add(getRoleByName(READ_ROLE).getId().toString()); } if (securityLevel.isAllowsWrite()) { roleIds.add(getRoleByName(WRITE_ROLE).getId().toString()); } if (securityLevel.isPartialRead()) { roleIds.add(getRoleByName(PARTIAL_READ_ROLE).getId().toString()); } if (securityLevel.isPartialWrite()) { roleIds.add(getRoleByName(PARTIAL_WRITE_ROLE).getId().toString()); } try { authMgr.assignGroupRoleToProtectionGroup(pg.getProtectionGroupId().toString(), targetGroup.getGroupId().toString(), roleIds.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); } catch (final CSTransactionException e) { LOG.warn("Could not assign project group roles corresponding to profile " + e.getMessage(), e); } }