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:org.sipfoundry.sipxconfig.dialplan.config.MappingRulesTest.java
public void testGenerateInternalRuleWithSourcePermission() throws Exception { IMocksControl control = EasyMock.createNiceControl(); IDialingRule rule = control.createMock(IDialingRule.class); rule.isInternal();// w w w . java 2s .co m control.andReturn(true); rule.getHostPatterns(); control.andReturn(ArrayUtils.EMPTY_STRING_ARRAY); rule.getName(); control.andReturn(null); rule.getDescription(); control.andReturn("my rule description"); rule.getPatterns(); control.andReturn(new String[] { "xxx" }).anyTimes(); rule.isTargetPermission(); control.andReturn(false); rule.getTransforms(); control.andReturn(new Transform[0]); control.replay(); m_out.begin(); m_out.generate(rule); m_out.end(); Document document = m_out.getDocument(); String domDoc = TestHelper.asString(document); assertXpathEvaluatesTo("my rule description", "/mappings/hostMatch/userMatch/description", domDoc); assertXpathEvaluatesTo("xxx", "/mappings/hostMatch/userMatch/userPattern", domDoc); assertXpathNotExists("/mappings/hostMatch/userMatch/permissionMatch/permission", domDoc); control.verify(); }
From source file:org.sipfoundry.sipxconfig.phone.snom.SnomProfileContext.java
/** * Create SNOM speed dial information//from w w w .j a v a2 s . com * * @return and array of at most 33 (0-32) phone numbers */ String[] getNumbers() { if (m_speedDial == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } List<Button> buttons = m_speedDial.getButtons(); int size = Math.min(SPEEDDIAL_MAX, buttons.size()); String[] numbers = new String[size]; for (int i = 0; i < numbers.length; i++) { numbers[i] = buttons.get(i).getNumber(); } return numbers; }
From source file:org.sipfoundry.sipxconfig.site.branch.BranchTableModel.java
public Iterator getCurrentPageRows(int firstRow, int pageSize, ITableColumn objSortColumn, boolean orderAscending) { String[] orderBy = objSortColumn != null ? new String[] { objSortColumn.getColumnName() } : ArrayUtils.EMPTY_STRING_ARRAY; if (!isSearchMode() || StringUtils.isBlank(m_queryText)) { return m_branchManager.loadBranchesByPage(firstRow, pageSize, orderBy, orderAscending).iterator(); }//from ww w . j av a 2 s . c om IdentityToBean identityToBean = new IdentityToBean(m_branchManager); return m_searchManager .search(Branch.class, m_queryText, firstRow, pageSize, orderBy, orderAscending, identityToBean) .iterator(); }
From source file:org.sipfoundry.sipxconfig.site.common.AssetSelectorMultiple.java
public IPropertySelectionModel getAssetSelectionModel() { File assetDir = new File(getAssetDir()); // make sure it exists assetDir.mkdirs();/* www . ja v a 2s . c o m*/ // list only files String[] assets = assetDir.list(FileFileFilter.FILE); if (assets == null) { assets = ArrayUtils.EMPTY_STRING_ARRAY; } return new StringPropertySelectionModel(assets); }
From source file:org.sipfoundry.sipxconfig.site.conference.ConferencesTableModel.java
public Iterator getCurrentPageRows(int firstRow, int pageSize, ITableColumn objSortColumn, boolean orderAscending) { String[] orderBy = objSortColumn != null ? new String[] { objSortColumn.getColumnName() } : ArrayUtils.EMPTY_STRING_ARRAY; if (!isSearchMode() || StringUtils.isBlank(m_queryText)) { return m_conferenceContext.filterConferencesByPage(m_bridge.getId(), m_groupId, firstRow, pageSize, orderBy, orderAscending).iterator(); }//from w w w . j av a 2 s . c o m IdentityToBean identityToBean = new IdentityToBean(m_identity); return m_conferenceContext.searchConferences(m_queryText).iterator(); }
From source file:org.sipfoundry.sipxconfig.site.phone.PhoneTableModel.java
/** * Translates table column to array of phone properties. It is safe to call with null - emtpy * array is returned in such case/*from w ww . j a va 2 s. c o m*/ * * HACK: this is dangerously dependend on relation between the table column name and the * properties names * * @param objSortColumn column object * @return array of strings by which we need to sort the table */ public static String[] orderByFromSortColum(ITableColumn objSortColumn) { if (objSortColumn == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } String[] orderBy = new String[] { objSortColumn.getColumnName() }; // fix for modelId case if ("modelId".equals(orderBy[0])) { return new String[] { "beanId", orderBy[0] }; } return orderBy; }
From source file:org.soaplab.services.cmdline.BaseParameter.java
/************************************************************************** * **************************************************************************/ public String[] createArg(Map<String, Object> inputs, Job job) throws ParameterException { if (paramDef.is(ParamDef.ENVAR)) return ArrayUtils.EMPTY_STRING_ARRAY; return build(inputs, job, CMD, false).toArray(new String[] {}); }
From source file:org.soaplab.services.cmdline.ChoiceListParameter.java
/************************************************************************** * Extract and return values for this parameter from 'inputs', or * from default. Actually, it does not return values from * 'inputs', but if the 'inputs' have a TRUE value for this * parameter, then the tag of this parameter is returned as its * value./* w w w . j ava 2 s . c o m*/ * * Return an empty array (not null) if there was no value in * 'inputs' and no default value is defined. * * The returned value can have more values because this parameter * represents zero, one or more booleans. * * Parameter 'job' (where this parameter belongs to) is not used * here. **************************************************************************/ protected String[] getValues(Map<String, Object> inputs, Job job) throws ParameterException { List<String> values = new ArrayList<String>(); // look for values of individual 'bools' which are subparts of // this parameter, concatenate values if more of them found for (ParamDef boolDef : ((ChoiceParamDef) paramDef).bools) { // extract value from input - look only for TRUE, // and ignore default value, for now Object value = ignoreArray(inputs.get(boolDef.id)); if (value != null && StringUtils.isNotBlank(value.toString())) if (BooleanUtils.toBoolean(value.toString())) { // if a TRUE value found, add it to the result values.add(boolDef.get(ParamDef.TAG)); } } if (values.size() > 0) return values.toArray(new String[] {}); // if we have not found _any_ value... boolean useDefaults = paramDef.is(ParamDef.USE_DEFAULTS); // for ZERO_OR_MORE type, and without a need to use defaults, // just return an empty array if (((ChoiceParamDef) paramDef).choiceType == ChoiceParamDef.ZERO_OR_MORE && !useDefaults) { return ArrayUtils.EMPTY_STRING_ARRAY; } // for ONE_OR_MORE type, look for defaults (if there are more // default values I am adding them here all, but AppLab1 was // just taking the last found value - what is more correct?) for (ParamDef boolDef : ((ChoiceParamDef) paramDef).bools) { // if a positive default found, remember it (it may be // used if USE_DEFAULTS is on) if (BooleanUtils.toBoolean(boolDef.dflt)) { values.add(boolDef.get(ParamDef.TAG)); } } if (values.size() > 0 && useDefaults) return values.toArray(new String[] {}); // if the value is still empty, we have a problem because the // choice type must be now ONE_OR_MORE - and we have nothing, // what a shame... throw new ParameterException(paramDef.id, "At least one option must be specified for: " + paramDef.get(SoaplabConstants.DATA_PROMPT)); }
From source file:org.soaplab.services.cmdline.ChoiceParameter.java
/************************************************************************** * Extract and return value for this parameter from 'inputs', or * from default. Actually, it does not return a value from * 'inputs', but if the 'inputs' have a TRUE value for this * parameter, then the tag of this parameter is returned as its * value./*from www . jav a2s .co m*/ * * Return an empty array (not null) if there was no value in * 'inputs' and no default value is defined. * * The returned array is expected to have always maximum one * element. * * Parameter 'job' (where this parameter belongs to) is not used * here. **************************************************************************/ protected String[] getValues(Map<String, Object> inputs, Job job) throws ParameterException { // look for values of individual 'bools' which are subparts of // this parameter, stop when the first is found for (ParamDef boolDef : ((ChoiceParamDef) paramDef).bools) { // extract value from input - look only for TRUE, // and ignore default value, for now Object value = ignoreArray(inputs.get(boolDef.id)); if (value != null && StringUtils.isNotBlank(value.toString())) if (BooleanUtils.toBoolean(value.toString())) { // a TRUE value found return new String[] { boolDef.get(ParamDef.TAG) }; } } // for ZERO_OR_ONE type, we do not need to use defaults, just // return an empty array if (((ChoiceParamDef) paramDef).choiceType == ChoiceParamDef.ZERO_OR_ONE) return ArrayUtils.EMPTY_STRING_ARRAY; // no defaults needed // for JUST_ONE type, if we are here it means that no value // was found - not for a single boolean sub-parameter; find // the first (should be the only one) default value for (ParamDef boolDef : ((ChoiceParamDef) paramDef).bools) { if (BooleanUtils.toBoolean(boolDef.dflt)) { // a TRUE default value found return new String[] { boolDef.get(ParamDef.TAG) }; } } // if we are here it means that no value was found for // JUST_ONE type (and no default was specified) throw new ParameterException(paramDef.id, "At least one option must be specified."); }
From source file:org.soaplab.services.cmdline.ChoiceParameter.java
/****************************************************************************** * ******************************************************************************/ public String[] createArg(Map<String, Object> inputs, Job job) throws ParameterException { if (paramDef.is(ParamDef.ENVAR)) return ArrayUtils.EMPTY_STRING_ARRAY; return build(inputs, job, CMD).toArray(new String[] {}); }