org.apache.commons.lang.ArrayUtils Java Examples
The following examples show how to use
org.apache.commons.lang.ArrayUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CryptoImpl.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private SigningCredential retrieveSigningCredential(String alias, KeyStore keyStore) { try { Certificate[] c = keyStore.getCertificateChain(alias); if (ArrayUtils.isEmpty(c)) { throw new IllegalArgumentException("The KeyStore doesn't contain the required key with alias [" + alias + "]"); } else { X509Certificate[] certificateChain = (X509Certificate[])Arrays.copyOf(c, c.length, X509Certificate[].class); PrivateKey privateKey = (PrivateKey)keyStore.getKey(alias, (char[])null); return SigningCredential.create(privateKey, Iterables.newList(certificateChain)); } } catch (KeyStoreException var6) { throw new IllegalArgumentException("Given keystore hasn't been initialized", var6); } catch (NoSuchAlgorithmException var7) { throw new IllegalStateException("There is a problem with the Security configuration... Check if all the required security providers are correctly registered", var7); } catch (UnrecoverableKeyException var8) { throw new IllegalStateException("The private key with alias [" + alias + "] could not be recovered from the given keystore", var8); } }
Example #2
Source File: ConfigurazioniConverter.java From govpay with GNU General Public License v3.0 | 6 votes |
private static it.govpay.bd.configurazione.model.Mail getConfigurazioneMailPromemoriaDTOPatch(MailTemplate mailPromemoria) throws ServiceException, ValidationException{ it.govpay.bd.configurazione.model.Mail dto = new it.govpay.bd.configurazione.model.Mail(); dto.setAllegaPdf(mailPromemoria.AllegaPdf()); dto.setTipo(mailPromemoria.getTipo()); if(mailPromemoria.getTipo() != null) { // valore tipo contabilita non valido if(it.govpay.backoffice.v1.beans.MailTemplate.TipoEnum.fromValue(mailPromemoria.getTipo()) == null) { throw new ValidationException("Codifica inesistente per tipo trasformazione. Valore fornito [" + mailPromemoria.getTipo() + "] valori possibili " + ArrayUtils.toString(it.govpay.backoffice.v1.beans.MailTemplate.TipoEnum.values())); } } // if(mailPromemoria.getMessaggio() != null && mailPromemoria.getMessaggio() instanceof String) // dto.setMessaggio((String) mailPromemoria.getMessaggio()); // else dto.setMessaggio((ConverterUtils.toJSON(mailPromemoria.getMessaggio(),null))); // if(mailPromemoria.getOggetto() != null && mailPromemoria.getOggetto() instanceof String) // dto.setOggetto((String) mailPromemoria.getOggetto()); // else dto.setOggetto((ConverterUtils.toJSON(mailPromemoria.getOggetto(),null))); return dto; }
Example #3
Source File: CSVApisUtil.java From sofa-acts with Apache License 2.0 | 6 votes |
/** * get .csv file path based on the class * * @param objClass * @param csvPath * @return */ private static String getCsvFileName(Class<?> objClass, String csvPath) { if (isWrapClass(objClass)) { LOG.warn("do nothing when simple type"); return null; } String[] paths = csvPath.split("/"); ArrayUtils.reverse(paths); String className = objClass.getSimpleName() + ".csv"; if (!StringUtils.equals(className, paths[0])) { csvPath = StringUtils.replace(csvPath, paths[0], className); } return csvPath; }
Example #4
Source File: StrTokenizerTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void test3() { String input = "a;b; c;\"d;\"\"e\";f; ; ;"; StrTokenizer tok = new StrTokenizer(input); tok.setDelimiterChar(';'); tok.setQuoteChar('"'); tok.setIgnoredMatcher(StrMatcher.noneMatcher()); tok.setIgnoreEmptyTokens(false); String tokens[] = tok.getTokenArray(); String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", "",}; assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); for (int i = 0; i < expected.length; i++) { assertTrue("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", ObjectUtils.equals(expected[i], tokens[i])); } }
Example #5
Source File: FileListUtils.java From incubator-gobblin with Apache License 2.0 | 6 votes |
private static List<FileStatus> listMostNestedPathRecursivelyHelper(FileSystem fs, List<FileStatus> files, FileStatus fileStatus, PathFilter fileFilter) throws IOException { if (fileStatus.isDirectory()) { FileStatus[] curFileStatus = fs.listStatus(fileStatus.getPath()); if (ArrayUtils.isEmpty(curFileStatus)) { files.add(fileStatus); } else { for (FileStatus status : curFileStatus) { listMostNestedPathRecursivelyHelper(fs, files, status, fileFilter); } } } else if (fileFilter.accept(fileStatus.getPath())) { files.add(fileStatus); } return files; }
Example #6
Source File: MultiMergeJoinMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public String getXML() { StringBuilder retval = new StringBuilder(); String[] inputStepsNames = inputSteps != null ? inputSteps : ArrayUtils.EMPTY_STRING_ARRAY; retval.append( " " ).append( XMLHandler.addTagValue( "join_type", getJoinType() ) ); for ( int i = 0; i < inputStepsNames.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "step" + i, inputStepsNames[ i ] ) ); } retval.append( " " ).append( XMLHandler.addTagValue( "number_input", inputStepsNames.length ) ); retval.append( " " ).append( XMLHandler.openTag( "keys" ) ).append( Const.CR ); for ( int i = 0; i < keyFields.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "key", keyFields[i] ) ); } retval.append( " " ).append( XMLHandler.closeTag( "keys" ) ).append( Const.CR ); return retval.toString(); }
Example #7
Source File: RandomPasswordProcessor.java From carbon-identity with Apache License 2.0 | 6 votes |
/** * Remove original passwords with random passwords when sending password properties to UI front-end * @param properties */ public Property[] removeOriginalPasswords(Property[] properties){ if (ArrayUtils.isEmpty(properties)){ return new Property[0]; } properties = addUniqueIdProperty(properties); String uuid = IdentityApplicationManagementUtil .getPropertyValue(properties, IdentityApplicationConstants.UNIQUE_ID_CONSTANT); String randomPhrase = IdentityApplicationConstants.RANDOM_PHRASE_PREFIX + uuid; RandomPassword[] randomPasswords = replaceOriginalPasswordsWithRandomPasswords( randomPhrase, properties); if (!ArrayUtils.isEmpty(randomPasswords)) { addPasswordContainerToCache(randomPasswords, uuid); } return properties; }
Example #8
Source File: StrTokenizerTest.java From astor with GNU General Public License v2.0 | 6 votes |
public void test2() { String input = "a;b;c ;\"d;\"\"e\";f; ; ;"; StrTokenizer tok = new StrTokenizer(input); tok.setDelimiterChar(';'); tok.setQuoteChar('"'); tok.setIgnoredMatcher(StrMatcher.noneMatcher()); tok.setIgnoreEmptyTokens(false); String tokens[] = tok.getTokenArray(); String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", "",}; assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); for (int i = 0; i < expected.length; i++) { assertTrue("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", ObjectUtils.equals(expected[i], tokens[i])); } }
Example #9
Source File: BaseRequestValidator.java From sunbird-lms-service with MIT License | 6 votes |
/** * Method to check whether given header fields present or not. * * @param data List of strings representing the header names in received request. * @param keys List of string represents the headers fields. */ public void checkMandatoryHeadersPresent(Map<String, String[]> data, String... keys) { if (MapUtils.isEmpty(data)) { throw new ProjectCommonException( ResponseCode.invalidRequestData.getErrorCode(), ResponseCode.invalidRequestData.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode()); } Arrays.stream(keys) .forEach( key -> { if (ArrayUtils.isEmpty(data.get(key))) { throw new ProjectCommonException( ResponseCode.mandatoryHeadersMissing.getErrorCode(), ResponseCode.mandatoryHeadersMissing.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode(), key); } }); }
Example #10
Source File: SerialMessage.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/** * Constructor. Creates a new instance of the SerialMessage class from a * specified buffer, and subsequently sets the node ID. * * @param nodeId the node the message is destined for * @param buffer the buffer to create the SerialMessage from. */ public SerialMessage(int nodeId, byte[] buffer) { logger.trace("NODE {}: Creating new SerialMessage from buffer = {}", nodeId, SerialMessage.bb2hex(buffer)); messageLength = buffer.length - 2; // buffer[1]; byte messageCheckSumm = calculateChecksum(buffer); byte messageCheckSummReceived = buffer[messageLength + 1]; if (messageCheckSumm == messageCheckSummReceived) { logger.trace("NODE {}: Checksum matched", nodeId); isValid = true; } else { logger.trace("NODE {}: Checksum error. Calculated = 0x%02X, Received = 0x%02X", nodeId, messageCheckSumm, messageCheckSummReceived); isValid = false; return; } this.priority = SerialMessagePriority.High; this.messageType = buffer[2] == 0x00 ? SerialMessageType.Request : SerialMessageType.Response; this.messageClass = SerialMessageClass.getMessageClass(buffer[3] & 0xFF); this.messagePayload = ArrayUtils.subarray(buffer, 4, messageLength + 1); this.messageNode = nodeId; logger.trace("NODE {}: Message payload = {}", getMessageNode(), SerialMessage.bb2hex(messagePayload)); }
Example #11
Source File: BonusService.java From aion-germany with GNU General Public License v3.0 | 6 votes |
public BonusItemGroup[] getGroupsByType(BonusType type) { switch (type) { case BOSS: return itemGroups.getBossGroups(); case ENCHANT: return itemGroups.getEnchantGroups(); case FOOD: return itemGroups.getFoodGroups(); case GATHER: return (BonusItemGroup[]) ArrayUtils.addAll(itemGroups.getOreGroups(), itemGroups.getGatherGroups()); case MANASTONE: return itemGroups.getManastoneGroups(); case MEDICINE: return itemGroups.getMedicineGroups(); case TASK: return itemGroups.getCraftGroups(); case MOVIE: return null; default: log.warn("Bonus of type " + type + " is not implemented"); return null; } }
Example #12
Source File: ErrorCollectorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public final List<String> getExceptionList(String... errorType) { List<String> exceptionList = new ArrayList(); if (ArrayUtils.contains(errorType, "WARN")) { exceptionList.addAll(this.exceptionWarningList); } if (ArrayUtils.contains(errorType, "ERROR")) { exceptionList.addAll(this.exceptionErrorList); } if (ArrayUtils.contains(errorType, "FATAL")) { exceptionList.addAll(this.exceptionFatalList); } return exceptionList; }
Example #13
Source File: TfMetaUtils.java From systemds with Apache License 2.0 | 6 votes |
public static int[] parseJsonObjectIDList(JSONObject spec, String[] colnames, String group) throws JSONException { int[] colList = new int[0]; boolean ids = spec.containsKey("ids") && spec.getBoolean("ids"); if( spec.containsKey(group) && spec.get(group) instanceof JSONArray ) { JSONArray colspecs = (JSONArray)spec.get(group); colList = new int[colspecs.size()]; for(int j=0; j<colspecs.size(); j++) { JSONObject colspec = (JSONObject) colspecs.get(j); colList[j] = ids ? colspec.getInt("id") : (ArrayUtils.indexOf(colnames, colspec.get("name")) + 1); if( colList[j] <= 0 ) { throw new RuntimeException("Specified column '" + colspec.get(ids?"id":"name")+"' does not exist."); } } //ensure ascending order of column IDs Arrays.sort(colList); } return colList; }
Example #14
Source File: RandomPasswordProcessor.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
/** * Remove random passwords with original passwords when sending password properties to Service Back-end * * @param properties */ public Property[] removeRandomPasswords(Property[] properties, boolean withCacheClear) { if (ArrayUtils.isEmpty(properties)) { return new Property[0]; } String uuid = IdentityApplicationManagementUtil.getPropertyValue(properties, IdentityApplicationConstants.UNIQUE_ID_CONSTANT); if (StringUtils.isBlank(uuid)) { if (log.isDebugEnabled()) { log.debug("Cache Key not found for Random Password Container"); } } else { properties = removeUniqueIdProperty(properties); RandomPassword[] randomPasswords = getRandomPasswordContainerFromCache(uuid, withCacheClear); if (!ArrayUtils.isEmpty(randomPasswords)) { replaceRandomPasswordsWithOriginalPasswords(properties, randomPasswords); } } return properties; }
Example #15
Source File: AuthenticationCertificateRegistrationServiceImpl.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public Result<X509Certificate[]> getCertificate(byte[] publicKeyIdentifier) throws TechnicalConnectorException { GetCertificateRequest request = new GetCertificateRequest(); RaUtils.setCommonAttributes(request); request.setPublicKeyIdentifier(publicKeyIdentifier); Result<GetCertificateResponse> resp = RaUtils.invokeCertRa(ConnectorXmlUtils.toString((Object)request), "urn:be:fgov:ehealth:etee:certra:protocol:v2:getcertificate", GetCertificateResponse.class); if (!resp.getStatus().equals(Status.OK)) { return resp.getStatus().equals(Status.PENDING) ? new Result(resp.getTime()) : new Result("Unable to obtain certificate", resp.getCause()); } else { X509Certificate[] x509Certificates = new X509Certificate[0]; byte[] x509Certificate; for(Iterator i$ = ((GetCertificateResponse)resp.getResult()).getX509Certificates().iterator(); i$.hasNext(); x509Certificates = (X509Certificate[])((X509Certificate[])ArrayUtils.add(x509Certificates, CertificateUtils.toX509Certificate(x509Certificate)))) { x509Certificate = (byte[])i$.next(); } return new Result(x509Certificates); } }
Example #16
Source File: HandlersLoader.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
static Handler<?>[] addingDefaultHandlers(Handler<?>[] result) { ArrayList<Class> requiredHandler = new ArrayList(defaultHandlers.size()); requiredHandler.addAll(defaultHandlers); CollectionUtils.filter(requiredHandler, new HandlersLoader.DefaultHandlersPredicate(result)); Iterator i$ = requiredHandler.iterator(); while(i$.hasNext()) { Class handler = (Class)i$.next(); try { LOG.debug("Adding required handler [{}]", handler.getName()); result = (Handler[])((Handler[])ArrayUtils.add(result, handler.newInstance())); } catch (Exception var5) { LOG.warn("Unable to add required handler", var5); } } return result; }
Example #17
Source File: IdPManagementUtil.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
/** * Use this method to replace original passwords with random passwords before sending to UI front-end * @param identityProvider * @return */ public static void removeOriginalPasswords(IdentityProvider identityProvider) { if (identityProvider == null || identityProvider.getProvisioningConnectorConfigs() == null) { return; } for (ProvisioningConnectorConfig provisioningConnectorConfig : identityProvider .getProvisioningConnectorConfigs()) { Property[] properties = provisioningConnectorConfig.getProvisioningProperties(); if (ArrayUtils.isEmpty(properties)) { continue; } properties = RandomPasswordProcessor.getInstance().removeOriginalPasswords(properties); provisioningConnectorConfig.setProvisioningProperties(properties); } }
Example #18
Source File: LengthCodedStringReader.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
public String readLengthCodedString(byte[] data) throws IOException { byte[] lengthBytes = ByteHelper.readBinaryCodedLengthBytes(data, getIndex()); long length = ByteHelper.readLengthCodedBinary(data, getIndex()); setIndex(getIndex() + lengthBytes.length); if (ByteHelper.NULL_LENGTH == length) { return null; } try { return new String(ArrayUtils.subarray(data, getIndex(), (int) (getIndex() + length)), encoding == null ? CODE_PAGE_1252 : encoding); } finally { setIndex((int) (getIndex() + length)); } }
Example #19
Source File: RolePermissionManagementServiceImpl.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
/** * Recursively go through UIPermissionNode. * * @param node UIPermissionNode of permissions. * @return Permission[] of permissions. */ private Permission[] getAllPermissions(UIPermissionNode node) { List<Permission> permissions = new ArrayList<>(); UIPermissionNode[] childNodes = node.getNodeList(); Permission permission = new Permission(); permission.setDisplayName(node.getDisplayName()); permission.setResourcePath(node.getResourcePath()); permissions.add(permission); if (ArrayUtils.isNotEmpty(childNodes)) { for (UIPermissionNode childNode : childNodes) { permissions.addAll(Arrays.asList(getAllPermissions(childNode))); } } return permissions.toArray(new Permission[0]); }
Example #20
Source File: ConfigurazioniConverter.java From govpay with GNU General Public License v3.0 | 6 votes |
private static it.govpay.bd.configurazione.model.Mail getConfigurazioneMailPromemoriaDTO(MailTemplate mailPromemoria) throws ServiceException, ValidationException{ it.govpay.bd.configurazione.model.Mail dto = new it.govpay.bd.configurazione.model.Mail(); dto.setAllegaPdf(mailPromemoria.AllegaPdf()); dto.setTipo(mailPromemoria.getTipo()); if(mailPromemoria.getTipo() != null) { // valore tipo contabilita non valido if(it.govpay.backoffice.v1.beans.MailTemplate.TipoEnum.fromValue(mailPromemoria.getTipo()) == null) { throw new ValidationException("Codifica inesistente per tipo trasformazione. Valore fornito [" + mailPromemoria.getTipo() + "] valori possibili " + ArrayUtils.toString(it.govpay.backoffice.v1.beans.MailTemplate.TipoEnum.values())); } } dto.setMessaggio((ConverterUtils.toJSON(mailPromemoria.getMessaggio(),null))); dto.setOggetto(ConverterUtils.toJSON(mailPromemoria.getOggetto(),null)); return dto; }
Example #21
Source File: SoapHeaderBlocksTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Checks if a CAR file is deployed. * * @param carFileName CAR file name. * @return True if exists, False otherwise. */ private Callable<Boolean> isCarFileDeployed(final String carFileName) { return new Callable<Boolean>() { @Override public Boolean call() throws ApplicationAdminExceptionException, RemoteException { log.info("waiting " + MAX_TIME + " millis for car deployment " + carFileName); Calendar startTime = Calendar.getInstance(); long time = Calendar.getInstance().getTimeInMillis() - startTime.getTimeInMillis(); String[] applicationList = applicationAdminClient.listAllApplications(); if (applicationList != null) { if (ArrayUtils.contains(applicationList, carFileName)) { log.info("car file deployed in " + time + " milliseconds"); return true; } } return false; } }; }
Example #22
Source File: ApplicationMgtValidator.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
/** * @param inboundAuthenticationConfig Inbound authentication configuration. * @param tenantDomain Tenant domain of application. * @param appId Application ID. * @throws IdentityApplicationManagementException IdentityApplicationManagementException. */ private void validateInboundAuthenticationConfig(InboundAuthenticationConfig inboundAuthenticationConfig, String tenantDomain, int appId) throws IdentityApplicationManagementException { if (inboundAuthenticationConfig == null) { return; } InboundAuthenticationRequestConfig[] inboundAuthRequestConfigs = inboundAuthenticationConfig .getInboundAuthenticationRequestConfigs(); if (ArrayUtils.isNotEmpty(inboundAuthRequestConfigs)) { for (InboundAuthenticationRequestConfig inboundAuthRequestConfig : inboundAuthRequestConfigs) { validateInboundAuthKey(inboundAuthRequestConfig, appId, tenantDomain); } } }
Example #23
Source File: BackfillFilter.java From bdf3 with Apache License 2.0 | 5 votes |
private Map<Class<?>,List<PropertyDescriptor>> getPropertyMap(Object entity) { if (propertyMap.isEmpty()) { Class<?> entityClass = ProxyBeanUtils.getProxyTargetType(entity); PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(entityClass); if (ArrayUtils.isNotEmpty(pds)) { for (PropertyDescriptor pd : pds) { for (CollectInfo collectInfo : collectInfos) { Class<?> cls = collectInfo.getEntityClass(); if (cls == null) { continue; } if (pd.getPropertyType().isAssignableFrom(cls)) { addPd2PropertyMap(cls, pd); } else if (Collection.class.isAssignableFrom(pd.getPropertyType())) { Type[] pts = ((ParameterizedType)pd.getReadMethod().getGenericReturnType()).getActualTypeArguments(); if (pts != null && pts.length > 0) { Type pt = pts[0]; if (pt instanceof Class && ((Class<?>) pt).isAssignableFrom(cls)) { addPd2PropertyMap(cls, pd); } } } } } } } return propertyMap; }
Example #24
Source File: SelectionModel.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public int[] getFullySelectedRows(int rowWidth) { final Set<Range> selectedRows = getSelectedRows(); int[] fullySelectedRows = new int[getSelectedRowCount()]; int index = 0; for (Range rowRange : selectedRows) { for (int i = rowRange.start; i < rowRange.end; i++) { if (isRowFullySelected(i, rowWidth)) { fullySelectedRows[index++] = i; } } } return index > 0 ? ArrayUtils.subarray(fullySelectedRows, 0, index) : new int[0]; }
Example #25
Source File: MtasDataLongBasic.java From mtas with Apache License 2.0 | 5 votes |
@Override public MtasDataCollector<?, ?> add(long[] values, int number) throws IOException { MtasDataCollector<?, ?> dataCollector = add(false); setValue(newCurrentPosition, ArrayUtils.toObject(values), number, newCurrentExisting); return dataCollector; }
Example #26
Source File: BlobUtil.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static Base64Binary generateXades(BlobType inValue, byte[] furnishedXades, String projectName) throws TechnicalConnectorException { if (projectName == null) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_INPUT_PARAMETER_NULL, new Object[]{"project name"}); } else { ConfigValidator props = ConfigFactory.getConfigValidator(); Boolean defaultValue = props.getBooleanProperty("${mycarenet.default.request.needxades}", false); if (props.getBooleanProperty("mycarenet." + projectName + ".request.needxades", defaultValue).booleanValue()) { return ArrayUtils.isEmpty(furnishedXades) ? generateXades(inValue, projectName) : convertXadesToBinary(furnishedXades); } else { return null; } } }
Example #27
Source File: CoveredColumnIndexCodec.java From phoenix with Apache License 2.0 | 5 votes |
private static void addColumnsToPut(Put indexInsert, List<ColumnEntry> columns) { // add each of the corresponding families to the put int count = 0; for (ColumnEntry column : columns) { indexInsert.add(INDEX_ROW_COLUMN_FAMILY, ArrayUtils.addAll(Bytes.toBytes(count++), toIndexQualifier(column.ref)), null); } }
Example #28
Source File: 1_StrBuilder.java From SimFix with GNU General Public License v2.0 | 5 votes |
/** * Copies part of the builder's character array into a new character array. * * @param startIndex the start index, inclusive, must be valid * @param endIndex the end index, exclusive, must be valid except that * if too large it is treated as end of string * @return a new array that holds part of the contents of the builder * @throws IndexOutOfBoundsException if startIndex is invalid, * or if endIndex is invalid (but endIndex greater than size is valid) */ public char[] toCharArray(int startIndex, int endIndex) { endIndex = validateRange(startIndex, endIndex); int len = endIndex - startIndex; if (len == 0) { return ArrayUtils.EMPTY_CHAR_ARRAY; } char chars[] = new char[len]; System.arraycopy(buffer, startIndex, chars, 0, len); return chars; }
Example #29
Source File: Arja_0022_t.java From coming with MIT License | 5 votes |
/** * Copies part of the builder's character array into a new character array. * * @param startIndex the start index, inclusive, must be valid * @param endIndex the end index, exclusive, must be valid except that * if too large it is treated as end of string * @return a new array that holds part of the contents of the builder * @throws IndexOutOfBoundsException if startIndex is invalid, * or if endIndex is invalid (but endIndex greater than size is valid) */ public char[] toCharArray(int startIndex, int endIndex) { endIndex = validateRange(startIndex, endIndex); int len = endIndex - startIndex; if (len == 0) { return ArrayUtils.EMPTY_CHAR_ARRAY; } char chars[] = new char[len]; System.arraycopy(buffer, startIndex, chars, 0, len); return chars; }
Example #30
Source File: DimensionService.java From Liudao with GNU General Public License v3.0 | 5 votes |
public List distinct(Event event, String[] condDimensions, EnumTimePeriod enumTimePeriod, String aggrDimension) { if (event == null || ArrayUtils.isEmpty(condDimensions) || enumTimePeriod == null || aggrDimension == null) { logger.error("参数错误"); return null; } Document query = new Document(); for (String dimension : condDimensions) { Object value = getProperty(event, dimension); if (value == null || "".equals(value)) { return null; } query.put(dimension, value); } query.put(Event.OPERATETIME, new Document("$gte", enumTimePeriod.getMinTime(event.getOperateTime())).append("$lte", enumTimePeriod.getMaxTime(event.getOperateTime()))); return mongoDao.distinct(event.getScene(), query, aggrDimension); }