List of usage examples for java.util Arrays copyOfRange
public static boolean[] copyOfRange(boolean[] original, int from, int to)
From source file:com.spectralogic.ds3client.utils.hashing.Md5Hash.java
public byte[] getHash() { return Arrays.copyOfRange(this.hash, 0, this.hash.length); }
From source file:com.titankingdoms.dev.titanchat.command.defaults.DebugCommand.java
@Override public void execute(CommandSender sender, String[] args) { if (args[0].equalsIgnoreCase("start")) { List<String> ids = Arrays.asList(Arrays.copyOfRange(args, 1, args.length)); for (String id : new ArrayList<String>(ids)) try { Debugger.startDebug(Integer.valueOf(id)); } catch (Exception e) { ids.remove(id);/*from ww w. java 2 s . c om*/ } Collections.sort(ids); sendMessage(sender, "&6Started debugging: " + StringUtils.join(ids, ", ")); } else if (args[0].equalsIgnoreCase("stop")) { List<String> ids = Arrays.asList(Arrays.copyOfRange(args, 1, args.length)); for (String id : new ArrayList<String>(ids)) try { Debugger.stopDebug(Integer.valueOf(id)); } catch (Exception e) { ids.remove(id); } Collections.sort(ids); sendMessage(sender, "&6Stopped debugging: " + StringUtils.join(ids, ", ")); } else { sendMessage(sender, "&4Incorrect usage: /titanchat debug " + getUsage()); } }
From source file:net.nperkins.quizmaster3000.AskQuestionRunnable.java
@Override public void run() { if (timer <= 0) { Bukkit.getScheduler().cancelTask(id); plugin.sendPlayers(plugin.getMessages().getString("quiz.question.timeup")); plugin.sendPlayers(MessageFormat.format(plugin.getMessages().getString("quiz.question.answer"), StringUtils.join(//from www.j a va 2s.co m Arrays.copyOfRange(plugin.getCurrentQuestion().getAnswer(), 0, plugin.getCurrentQuestion().getAnswer().length), plugin.getMessages().getString("quiz.answer.joiner")))); if (plugin.getScores().size() == 0) { plugin.sendPlayers(plugin.prefixMessage(plugin.getMessages().getString("error.allplayersleft"))); plugin.setState(QuizState.FINISHED); plugin.setRunning(false); } else { plugin.setState(QuizState.WAITFORNEXT); plugin.sendPlayers(plugin.getMessages().getString("quiz.question.next")); plugin.getWaitForNextRunnable().start(); } } else { plugin.sendPlayers( MessageFormat.format(plugin.getMessages().getString("quiz.question.timeleft"), timer)); if (plugin.getConfig().getBoolean("quiz.hints")) plugin.sendPlayers(MessageFormat.format(plugin.getMessages().getString("quiz.question.hint"), plugin.getHint(timer * 2))); timer -= 15; } }
From source file:com.liferay.jenkins.tools.BetweenTimestampsMatcher.java
public BetweenTimestampsMatcher(String[] optionValues) { int length = optionValues.length; if (isEven(length)) { String start = StringUtils.join(Arrays.copyOfRange(optionValues, 0, length / 2), ' '); String end = StringUtils.join(Arrays.copyOfRange(optionValues, length / 2, length), ' '); String[] args = new String[2]; setTimestamps(parseTimestamp(start), parseTimestamp(end)); } else {// ww w . jav a2s .c o m throw new IllegalArgumentException("between option require even number of parameters"); } }
From source file:D1WaveletTransform.java
private double[][] doWaveletTransformTest(double[] data, int window) { Transform t = new Transform(new FastWaveletTransform(new Haar1())); int position = 0; int frame = data.length; double[][] dataForSpectrogram = new double[frame / window * 2][]; for (int j = 0; j < dataForSpectrogram.length; j++) { double[] dataSource = Arrays.copyOfRange(data, position, position + window); if (dataSource.length % 2 != 0) { break; }//from ww w . j a va2 s. co m dataForSpectrogram[j] = t.forward(math.HammingWindow(dataSource, dataSource.length)); position += window / 2; } return dataForSpectrogram; }
From source file:au.org.ala.delta.editor.slotfile.Directive.java
public void setName(String[] name) { int i = 0;//from w w w .java 2s.c o m for (i = 0; i < name.length; i++) { if (StringUtils.isEmpty(name[i])) { break; } } _name = Arrays.copyOfRange(name, 0, i); }
From source file:com.blackducksoftware.integration.build.utils.FilePathGavExtractor.java
public Gav getMavenPathGav(final String filePath, final String localMavenRepoPath) { if (filePath == null || localMavenRepoPath == null) { return null; }/*from www. j a v a 2 s .c o m*/ final String cleanedFilePath = filePath.replaceFirst(localMavenRepoPath, ""); final String[] cleanedFilePathSegments = cleanedFilePath.split(File.separator); String[] groupIdSegments; if (cleanedFilePathSegments[0].equals("")) { if (cleanedFilePathSegments.length < 4) { return null; } groupIdSegments = Arrays.copyOfRange(cleanedFilePathSegments, 1, cleanedFilePathSegments.length - 3); } else { if (cleanedFilePathSegments.length < 3) { return null; } groupIdSegments = Arrays.copyOfRange(cleanedFilePathSegments, 0, cleanedFilePathSegments.length - 3); } final String groupId = StringUtils.join(groupIdSegments, "."); final String artifactId = cleanedFilePathSegments[cleanedFilePathSegments.length - 3]; final String version = cleanedFilePathSegments[cleanedFilePathSegments.length - 2]; return new Gav(groupId, artifactId, version); }
From source file:Main.java
public static byte[] aesIGEencrypt(byte[] tmpAESiv, byte[] tmpAesKey, byte[] data) { try {//w ww. ja v a 2 s . c om ByteBuffer out = ByteBuffer.allocate(data.length); byte[] ivp = Arrays.copyOfRange(tmpAESiv, 0, tmpAESiv.length / 2); byte[] iv2p = Arrays.copyOfRange(tmpAESiv, tmpAESiv.length / 2, tmpAESiv.length); int len = data.length / AES_BLOCK_SIZE; byte[] xorInput = null; byte[] xorOutput = null; SecretKeySpec keySpec = null; keySpec = new SecretKeySpec(tmpAesKey, "AES"); Cipher cipher = null; cipher = Cipher.getInstance("AES/ECB/NoPadding"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); byte[] input = null; byte[] output = null; for (int i = 0; i < len; i++) { input = Arrays.copyOfRange(data, i * AES_BLOCK_SIZE, (i + 1) * AES_BLOCK_SIZE); xorInput = xor(input, ivp); output = cipher.doFinal(xorInput); xorOutput = xor(output, iv2p); out.put(xorOutput); ivp = xorOutput; iv2p = input; } return out.array(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (IllegalBlockSizeException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } catch (InvalidKeyException e) { e.printStackTrace(); } return null; }
From source file:com.titankingdoms.dev.titanchat.command.defaults.PlaceCommand.java
@Override public void execute(CommandSender sender, Channel channel, String[] args) { Participant participant = plugin.getParticipantManager().getParticipant(args[0]); if (channel.isLinked(plugin.getParticipantManager().getParticipant(sender))) { sendMessage(sender, participant.getDisplayName() + " &4is already on the channel"); return;//from w w w. j ava2 s . co m } String reason = StringUtils.join(Arrays.copyOfRange(args, 1, args.length)); channel.link(participant); participant.notice("&4You have been placed in " + channel.getName() + ": " + reason); if (!channel.isLinked(plugin.getParticipantManager().getParticipant(sender))) sendMessage(sender, participant.getDisplayName() + " &6has been placed"); channel.notice(participant.getDisplayName() + " &6has been placed"); }
From source file:gobblin.kafka.serialize.MD5Digest.java
/** * Static method to get an MD5Digest from a binary byte representation. * @param md5Bytes/*from www . j a v a2 s . c o m*/ * @param offset in the byte array to start reading from * @return a filled out MD5Digest */ public static MD5Digest fromBytes(byte[] md5Bytes, int offset) { byte[] md5BytesCopy = Arrays.copyOfRange(md5Bytes, offset, offset + MD5_BYTES_LENGTH); //TODO: Replace this with a version that encodes without needing a copy. String md5String = Hex.encodeHexString(md5BytesCopy); return new MD5Digest(md5String, md5BytesCopy); }