Java Code Examples for org.apache.commons.lang.ArrayUtils#removeElement()
The following examples show how to use
org.apache.commons.lang.ArrayUtils#removeElement() .
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: RandomPasswordProcessor.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
private Property[] removeUniqueIdProperty(Property[] properties) { if (ArrayUtils.isEmpty(properties)) { return new Property[0]; } for (int i = 0; i < properties.length; i++) { if (properties[i] == null) { continue; } if (IdentityApplicationConstants.UNIQUE_ID_CONSTANT.equals(properties[i].getName())) { Property[] propertiesTemp = properties; if (log.isDebugEnabled()) { log.debug("Removing uniqueId property: " + properties[i].getName()); } properties = (Property[]) ArrayUtils.removeElement(properties, properties[i]); //Removing uniqueId property from existing properties too propertiesTemp[i] = null; } } return properties; }
Example 2
Source File: RandomPasswordProcessor.java From carbon-identity with Apache License 2.0 | 6 votes |
private Property[] removeUniqueIdProperty(Property [] properties) { if (ArrayUtils.isEmpty(properties)){ return new Property[0]; } for (int i=0 ; i < properties.length; i++) { if (properties[i] == null){ continue; } if (IdentityApplicationConstants.UNIQUE_ID_CONSTANT.equals(properties[i].getName())) { Property[] propertiesTemp = properties; if (log.isDebugEnabled()){ log.debug("Removing uniqueId property: " + properties[i].getName()); } properties = (Property[])ArrayUtils.removeElement(properties, properties[i]); //Removing uniqueId property from existing properties too propertiesTemp[i] = null; } } return properties; }
Example 3
Source File: WordVectorsImpl.java From deeplearning4j with Apache License 2.0 | 6 votes |
/** * This method returns 2D array, where each row represents corresponding label * * @param labels * @return */ @Override public INDArray getWordVectors(@NonNull Collection<String> labels) { int indexes[] = new int[labels.size()]; int cnt = 0; boolean useIndexUnknown = useUnknown && vocab.containsWord(getUNK()); for (String label : labels) { if (vocab.containsWord(label)) { indexes[cnt] = vocab.indexOf(label); } else indexes[cnt] = useIndexUnknown ? vocab.indexOf(getUNK()) : -1; cnt++; } while (ArrayUtils.contains(indexes, -1)) { indexes = ArrayUtils.removeElement(indexes, -1); } if (indexes.length == 0) { return Nd4j.empty(((InMemoryLookupTable)lookupTable).getSyn0().dataType()); } INDArray result = Nd4j.pullRows(lookupTable.getWeights(), 1, indexes); return result; }
Example 4
Source File: IgniteRepositoryQuery.java From ignite with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} @param values the values * * @return the object */ @Override public Object execute(Object[] values) { Object[] parameters = values; // config via Query annotation (dynamicQuery = false) DynamicQueryConfig config = staticQueryConfiguration; // or condition to allow query tunning if (config == null || dynamicQueryConfigurationIndex != -1) { DynamicQueryConfig newConfig = (DynamicQueryConfig)values[dynamicQueryConfigurationIndex]; parameters = ArrayUtils.removeElement(parameters, dynamicQueryConfigurationIndex); if (newConfig != null) { // upset query configuration config = newConfig; } } // query configuration is required, via Query annotation or per parameter (within provided values param) if (config == null) { throw new IllegalStateException( "Unable to execute query. When passing dynamicQuery = true via org.apache.ignite.springdata" + ".repository.config.Query annotation, you must provide a non null method parameter of type " + "DynamicQueryConfig"); } IgniteQuery qry = getQuery(config); ReturnStrategy returnStgy = getReturnStgy(qry); Query iQry = prepareQuery(qry, config, returnStgy, parameters); QueryCursor qryCursor = cache.query(iQry); return transformQueryCursor(qry, returnStgy, parameters, qryCursor); }
Example 5
Source File: IgniteRepositoryQuery.java From ignite with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} @param values the values * * @return the object */ @Override public Object execute(Object[] values) { Object[] parameters = values; // config via Query annotation (dynamicQuery = false) DynamicQueryConfig config = staticQueryConfiguration; // or condition to allow query tunning if (config == null || dynamicQueryConfigurationIndex != -1) { DynamicQueryConfig newConfig = (DynamicQueryConfig)values[dynamicQueryConfigurationIndex]; parameters = ArrayUtils.removeElement(parameters, dynamicQueryConfigurationIndex); if (newConfig != null) { // upset query configuration config = newConfig; } } // query configuration is required, via Query annotation or per parameter (within provided values param) if (config == null) { throw new IllegalStateException( "Unable to execute query. When passing dynamicQuery = true via org.apache.ignite.springdata" + ".repository.config.Query annotation, you must provide a non null method parameter of type " + "DynamicQueryConfig"); } IgniteQuery qry = getQuery(config); ReturnStrategy returnStgy = getReturnStgy(qry); Query iQry = prepareQuery(qry, config, returnStgy, parameters); QueryCursor qryCursor = cache.query(iQry); return transformQueryCursor(qry, returnStgy, parameters, qryCursor); }
Example 6
Source File: OAuthApplicationMgtListener.java From carbon-identity with Apache License 2.0 | 5 votes |
private void removeClientSecret(ServiceProvider serviceProvider) { InboundAuthenticationConfig inboundAuthenticationConfig = serviceProvider.getInboundAuthenticationConfig(); if (inboundAuthenticationConfig != null) { InboundAuthenticationRequestConfig[] inboundRequestConfigs = inboundAuthenticationConfig. getInboundAuthenticationRequestConfigs(); if (inboundRequestConfigs != null) { for (InboundAuthenticationRequestConfig inboundRequestConfig : inboundRequestConfigs) { if (inboundRequestConfig.getInboundAuthType().equals(OAUTH2)) { Property[] props = inboundRequestConfig.getProperties(); for (Property prop : props) { if (prop.getName().equalsIgnoreCase(OAUTH2_CONSUMER_SECRET)) { props = (Property[]) ArrayUtils.removeElement(props, prop); inboundRequestConfig.setProperties(props); continue; //we are interested only on this property } else { //ignore } } continue;// we are interested only on oauth2 config. Only one will be present. } else { //ignore } } } else { //ignore } } else { //nothing to do } }
Example 7
Source File: EmoServiceWithZK.java From emodb with Apache License 2.0 | 4 votes |
public static void main(String... args) throws Exception { // Remove all nulls and empty strings from the argument list. This can happen as if the maven command // starts the service with no permission YAML files. args = Arrays.stream(args).filter(arg -> !Strings.isNullOrEmpty(arg)).toArray(String[]::new); // Start cassandra if necessary (cassandra.yaml is provided) ArgumentParser parser = ArgumentParsers.newArgumentParser("java -jar emodb-web-local*.jar"); parser.addArgument("server").required(true).help("server"); parser.addArgument("emo-config").required(true).help("config.yaml - EmoDB's config file"); parser.addArgument("emo-config-ddl").required(true).help("config-ddl.yaml - EmoDB's cassandra schema file"); parser.addArgument("cassandra-yaml").nargs("?").help("cassandra.yaml - Cassandra configuration file to start an" + " in memory embedded Cassandra."); parser.addArgument("-z","--zookeeper").dest("zookeeper").action(Arguments.storeTrue()).help("Starts zookeeper"); parser.addArgument("-p","--permissions-yaml").dest("permissions").nargs("*").help("Permissions file(s)"); // Get the path to cassandraYaml or if zookeeper is available Namespace result = parser.parseArgs(args); String cassandraYaml = result.getString("cassandra-yaml"); boolean startZk = result.getBoolean("zookeeper"); String emoConfigYaml = result.getString("emo-config"); List<String> permissionsYamls = result.getList("permissions"); String[] emoServiceArgs = args; // Start ZooKeeper TestingServer zooKeeperServer = null; if (startZk) { zooKeeperServer = isLocalZooKeeperRunning() ? null : startLocalZooKeeper(); emoServiceArgs = (String[]) ArrayUtils.removeElement(args, "-z"); emoServiceArgs = (String[]) ArrayUtils.removeElement(emoServiceArgs, "--zookeeper"); } boolean success = false; if (cassandraYaml != null) { // Replace $DIR$ so we can correctly specify location during runtime File templateFile = new File(cassandraYaml); String baseFile = Files.toString(templateFile, Charset.defaultCharset()); // Get the jar location String path = EmoServiceWithZK.class.getProtectionDomain().getCodeSource().getLocation().getPath(); String parentDir = new File(path).getParent(); String newFile = baseFile.replace("$DATADIR$", new File(parentDir, "data").getAbsolutePath()); newFile = newFile.replace("$COMMITDIR$", new File(parentDir, "commitlog").getAbsolutePath()); newFile = newFile.replace("$CACHEDIR$", new File(parentDir, "saved_caches").getAbsolutePath()); File newYamlFile = new File(templateFile.getParent(), "emo-cassandra.yaml"); Files.write(newFile, newYamlFile, Charset.defaultCharset()); startLocalCassandra(newYamlFile.getAbsolutePath()); emoServiceArgs = (String[]) ArrayUtils.removeElement(emoServiceArgs, cassandraYaml); } // If permissions files were configured remove them from the argument list int permissionsIndex = Math.max(ArrayUtils.indexOf(emoServiceArgs, "-p"), ArrayUtils.indexOf(emoServiceArgs, "--permissions-yaml")); if (permissionsIndex >= 0) { int permissionsArgCount = 1 + permissionsYamls.size(); for (int i=0; i < permissionsArgCount; i++) { emoServiceArgs = (String[]) ArrayUtils.remove(emoServiceArgs, permissionsIndex); } } try { EmoService.main(emoServiceArgs); success = true; setPermissionsFromFiles(permissionsYamls, emoConfigYaml); } catch (Throwable t) { t.printStackTrace(); } finally { // The main web server command returns immediately--don't stop ZooKeeper/Cassandra in that case. if (zooKeeperServer != null && !(success && args.length > 0 && "server".equals(args[0]))) { zooKeeperServer.stop(); service.shutdown(); } } }
Example 8
Source File: AllReader.java From dynaform with Artistic License 2.0 | 4 votes |
private XmlReader createNextReader(int removeIndex) { return new ItemReader(ArrayUtils.removeElement(unselectedIndexes, removeIndex)); }