List of usage examples for java.util LinkedList toArray
public Object[] toArray()
From source file:org.jpos.space.HzlSpace.java
public void notifyListeners(Object key, Object value) { Object[] listeners = null;//from w ww. j av a 2 s . c om synchronized (this) { if (sl == null) return; LinkedList<Object> l = (LinkedList<Object>) sl.entries.get(key); if (l != null) listeners = l.toArray(); } if (listeners != null) { for (int i = 0; i < listeners.length; i++) { Object o = listeners[i]; if (o instanceof Expirable) o = ((Expirable) o).getValue(); if (o instanceof SpaceListener) ((SpaceListener) o).notify(key, value); } } }
From source file:io.syndesis.jsondb.impl.SqlJsonDB.java
private int deleteJsonRecords(Handle dbi, String baseDBPath, String like) { LinkedList<String> params = getAllParentPaths(baseDBPath); StringBuilder sql = new StringBuilder("DELETE from jsondb where path LIKE ?"); if (!params.isEmpty()) { sql.append(" OR path in ( ").append(String.join(", ", Collections.nCopies(params.size(), "?"))) .append(" )"); }/* ww w.j a v a 2 s . com*/ params.addFirst(like); return dbi.update(sql.toString(), params.toArray()); }
From source file:org.apache.hama.ml.recommendation.cf.OnlineCF.java
private DoubleMatrix convertVectorWritable(VectorWritable value) { //format of array: matrix_rank, matrix_converted_to_vector DoubleVector vc = value.getVector(); int matrix_rank = (int) vc.get(0); int matrix_size = vc.getLength() - 1; LinkedList<DoubleVector> slices = new LinkedList<DoubleVector>(); int offset = 1; while (offset < matrix_size) { slices.add(vc.slice(offset, matrix_rank)); offset += matrix_rank;/*from ww w. j av a2 s .c o m*/ } DoubleMatrix res = new DenseDoubleMatrix((DoubleVector[]) slices.toArray()); return res; }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModel.java
public TreePath getTreePathForSelection(FileObject selectedFolder, final String selection) throws FileSystemException { if (root.getRoot() == null) { return null; }/*from w w w. j a v a 2s . co m*/ if (root.getRoot().equals(selectedFolder)) { return new TreePath(root); } final LinkedList<Object> list = new LinkedList<Object>(); while (selectedFolder != null) { list.add(0, selectedFolder); final FileObject parent = selectedFolder.getParent(); if (selectedFolder.equals(parent)) { break; } if (root.getRoot().equals(parent)) { break; } selectedFolder = parent; } list.add(0, root); return new TreePath(list.toArray()); }
From source file:org.pentaho.repo.controller.RepositoryBrowserController.java
public LinkedList<String> storeRecentSearch(String recentSearch) { LinkedList<String> recentSearches = getRecentSearches(); try {//from w w w . j a va2 s . co m if (recentSearch == null || recentSearches.contains(recentSearch)) { return recentSearches; } recentSearches.push(recentSearch); if (recentSearches.size() > 5) { recentSearches.pollLast(); } JSONArray jsonArray = new JSONArray(); CollectionUtils.addAll(jsonArray, recentSearches.toArray()); PropsUI props = PropsUI.getInstance(); String jsonValue = props.getRecentSearches(); JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = jsonValue != null ? (JSONObject) jsonParser.parse(jsonValue) : new JSONObject(); String login = "file_repository_no_login"; if (Spoon.getInstance().rep.getUserInfo() != null) { login = Spoon.getInstance().rep.getUserInfo().getLogin(); } jsonObject.put(login, jsonArray); props.setRecentSearches(jsonObject.toJSONString()); } catch (Exception e) { // Log error in console } return recentSearches; }
From source file:org.apache.cocoon.forms.binding.MultiValueJXPathBinding.java
public void doLoad(Widget frmModel, JXPathContext jctx) throws BindingException { Widget widget = selectWidget(frmModel, this.multiValueId); if (widget == null) { throw new BindingException("The widget with the ID [" + this.multiValueId + "] referenced in the binding does not exist in the form definition."); }/*w ww . j a va 2 s.c om*/ // Move to multi value context Pointer ptr = jctx.getPointer(this.multiValuePath); if (ptr.getNode() != null) { // There are some nodes to load from JXPathContext multiValueContext = jctx.getRelativeContext(ptr); // build a jxpath iterator for pointers Iterator rowPointers = multiValueContext.iterate(this.rowPath); LinkedList list = new LinkedList(); while (rowPointers.hasNext()) { Object value = rowPointers.next(); if (value != null && convertor != null) { if (value instanceof String) { ConversionResult conversionResult = convertor.convertFromString((String) value, convertorLocale, null); if (conversionResult.isSuccessful()) value = conversionResult.getResult(); else value = null; } else { getLogger().warn("Convertor ignored on backend-value which isn't of type String."); } } list.add(value); } widget.setValue(list.toArray()); } if (getLogger().isDebugEnabled()) getLogger().debug("done loading values " + toString()); }
From source file:com.game.ui.views.CharacterEditor.java
/** * This method draws up the gui on the panel. *//*w w w .j av a 2 s. c o m*/ public void doGui() { JPanel outerPane = new JPanel(); outerPane.setLayout(new GridBagLayout()); // setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel noteLbl = new JLabel(lblContent); noteLbl.setAlignmentX(0); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(5, 5, 5, 5); c.gridwidth = 4; c.gridy = 0; c.gridx = 0; outerPane.add(noteLbl, c); System.out.println(c.gridy); c.gridy++; System.out.println(c.gridy); c.gridx = 0; c.gridwidth = 1; comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1); comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setAlignmentX(0); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); outerPane.add(comboBox, c); c.gridy++; JLabel nameLbl = new JLabel("Name : "); outerPane.add(nameLbl, c); c.gridx++; name = new JTextField(); name.setColumns(20); outerPane.add(name, c); c.gridx = 0; c.gridy++; JLabel imageLbl = new JLabel("Image Path : "); outerPane.add(imageLbl, c); c.gridx++; imgPath = new JTextField(); imgPath.setColumns(20); outerPane.add(imgPath, c); c.gridx = 0; c.gridy++; JLabel hitPtsLbl = new JLabel("Hit Points : "); outerPane.add(hitPtsLbl, c); c.gridx++; hitPoints = new JTextField(); hitPoints.setColumns(20); outerPane.add(hitPoints, c); c.gridx = 0; c.gridy++; JLabel lvl = new JLabel("Level : "); outerPane.add(lvl, c); c.gridx++; level = new JTextField(); level.setColumns(20); /*if(!isEnemy){ level.setText("1"); level.setEnabled(false); }*/ outerPane.add(level, c); c.gridx = 0; c.gridy++; JLabel mlWpn = new JLabel("Melee Weapon : "); outerPane.add(mlWpn, c); c.gridx++; model = new DefaultComboBoxModel(); LinkedList<String> meleeWpnList = new LinkedList<String>(); LinkedList<String> rngdWpnList = new LinkedList<String>(); for (Item item : GameBean.weaponDetails) { Weapon wpn = (Weapon) item; if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[0])) { meleeWpnList.add(wpn.getName()); } else { rngdWpnList.add(wpn.getName()); } weaponMap.put(wpn.getName(), wpn); } meleeWeapon = new JComboBox(new DefaultComboBoxModel(meleeWpnList.toArray())); meleeWeapon.setSelectedIndex(-1); meleeWeapon.setMaximumSize(new Dimension(100, 30)); outerPane.add(meleeWeapon, c); c.gridx++; JLabel rngdWpn = new JLabel("Ranged Weapon : "); outerPane.add(rngdWpn, c); c.gridx++; rangedWeapon = new JComboBox(new DefaultComboBoxModel(rngdWpnList.toArray())); rangedWeapon.setSelectedIndex(-1); rangedWeapon.setMaximumSize(new Dimension(100, 30)); outerPane.add(rangedWeapon, c); c.gridy++; c.gridx = 0; JLabel armourLbl = new JLabel("Armour : "); outerPane.add(armourLbl, c); c.gridx++; LinkedList<String> armourList = new LinkedList<String>(); LinkedList<String> shildList = new LinkedList<String>(); for (Item item : GameBean.armourDetails) { Armour temp = (Armour) item; if (temp.getArmourType() != null) { if (temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[1])) { armourList.add(temp.getName()); } else { shildList.add(temp.getName()); } } else { armourList.add(temp.getName()); // else if(temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[2])) shildList.add(temp.getName()); } armorMap.put(temp.getName(), temp); } armour = new JComboBox(new DefaultComboBoxModel(armourList.toArray())); armour.setSelectedIndex(-1); armour.setMaximumSize(new Dimension(100, 30)); outerPane.add(armour, c); c.gridx++; JLabel shieldLbl = new JLabel("Shield : "); outerPane.add(shieldLbl, c); c.gridx++; shield = new JComboBox(new DefaultComboBoxModel(shildList.toArray())); shield.setSelectedIndex(-1); shield.setMaximumSize(new Dimension(100, 30)); outerPane.add(shield, c); ta = new JTextArea(10, 50); ta.setRows(40); ta.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); JScrollPane scrollPane = new JScrollPane(ta); scrollPane.setPreferredSize(new Dimension(600, 250)); c.gridx = 0; c.gridy++; c.fill = GridBagConstraints.BOTH; c.gridwidth = 4; c.gridheight = 4; c.weightx = .5; c.weighty = 1; outerPane.add(scrollPane, c); c.gridy += 4; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.gridheight = 1; c.gridwidth = 1; JButton generate = new JButton("Generate"); JButton submit = new JButton("Submit"); outerPane.add(generate, c); submit.addActionListener(this); generate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ta.setText(""); HashSet<Integer> set = new HashSet<Integer>(); int strength = getUniqueVal(set); int constitution = getUniqueVal(set); int dext = getUniqueVal(set); int intel = getUniqueVal(set); int charisma = getUniqueVal(set); int wisdom = getUniqueVal(set); if (character == null) { builder = new CharacterBuilder(isEnemy); } else { builder = new CharacterBuilder(character); } builder.setStrength(strength); builder.setConstitution(constitution); builder.setDexterity(dext); builder.setIntelligence(intel); builder.setCharisma(charisma); builder.setWisdom(wisdom); int strModifier = GameUtils.calculateAbilityModifier(strength); int conModifier = GameUtils.calculateAbilityModifier(constitution); int dexModifier = GameUtils.calculateAbilityModifier(dext); int wisModifier = GameUtils.calculateAbilityModifier(wisdom); int intModifier = GameUtils.calculateAbilityModifier(intel); int chaModifier = GameUtils.calculateAbilityModifier(charisma); builder.setStrengthModifier(strModifier); builder.setConstitutionModifier(conModifier); builder.setCharismaModifier(chaModifier); builder.setWisdomModifier(wisModifier); builder.setIntelligenceModifier(intModifier); builder.setDexterityModifier(dexModifier); String type = null; if (constitution < strength && constitution > dext) { type = "Bully"; builder.setType("Bully"); } else if (dext > constitution && constitution > strength) { builder.setType("Nimble"); type = "Nimble"; } else { builder.setType("Tank"); type = "Tank"; } ta.append("Strength : " + strength); ta.append("\nDexterity : " + dexModifier); ta.append("\nConstitution : " + constitution); ta.append("\nIntelligence : " + intel); ta.append("\nCharisma: " + charisma); ta.append("\nWisdom : " + wisdom); ta.append("\nType :" + type); ta.append("\nStrength Modifier :" + strModifier); ta.append("\nConstitution Modifier :" + conModifier); ta.append("\nDexterity Modifier :" + dexModifier); generated = true; if (character != null) { character = builder.build(); } } }); c.gridx++; outerPane.add(submit, c); validationMess = new JLabel(); validationMess.setForeground(Color.red); // validationMess.setVisible(false); c.gridy++; c.gridx = 0; c.gridwidth = 4; outerPane.add(validationMess, c); JScrollPane outerScrollPane = new JScrollPane(outerPane); setLayout(new BorderLayout()); add(outerScrollPane, BorderLayout.CENTER); }
From source file:org.vast.stt.provider.tiling.TiledMapProvider.java
@Override public void updateData() throws DataException { // init DataNode if not done yet if (!dataNode.isNodeStructureReady()) init();/*w ww . j a v a 2 s .co m*/ // convert extent to tile system projection SpatialExtent newExtent = transformBbox(spatialExtent); // query tree for matching and unused items itemsToLoad.clear(); itemsToHide.clear(); itemsToDiscard.clear(); tileSelector.setROI(newExtent); tileSelector.setCurrentLevel(0); double tileRatio = spatialExtent.getXTiles() * spatialExtent.getYTiles(); tileSelector.setSizeRatio(tileRatio * 0.35); tileSelector.setMaxDistance(Math.sqrt(tileRatio)); tileSelector.setHidePartiallyVisibleParents(useAlpha); quadTree.accept(tileSelector); // remove hidden items from block lists while (!itemsToHide.isEmpty()) { QuadTreeItem item = itemsToHide.poll(); BlockListItem[] itemBlocks = (BlockListItem[]) item.getData(); if (itemBlocks != null) for (int b = 0; b < itemBlocks.length; b++) blockLists[b].remove(itemBlocks[b]); } // send event for redraw if (!canceled) dispatchEvent(new STTEvent(this, EventType.PROVIDER_DATA_CHANGED), true); // discard items if (itemsToDiscard.size() > 0) { LinkedList<Object> blocksToDiscard = new LinkedList<Object>(); while (!itemsToDiscard.isEmpty()) { QuadTreeItem item = itemsToDiscard.poll(); // add blocks to be deleted BlockListItem[] itemBlocks = (BlockListItem[]) item.getData(); if (itemBlocks != null && blockLists[0].contains(itemBlocks[0])) log.debug(">>>>" + itemBlocks[0] + " STILL IN LIST !!"); if (itemBlocks != null)// && !blockLists[0].contains(itemBlocks[0])) for (int b = 0; b < itemBlocks.length; b++) blocksToDiscard.add(itemBlocks[b]); item.setData(null); // need to make sure we don't have children with data // since they can still have associated textures and DL // if not, we can even remove quad tree item //if (!item.hasChildren()) // item.removeFromParent(); } //System.out.println(blocksToDiscard.size() + " items to be deleted"); if (blocksToDiscard.size() > 0) dispatchEvent(new STTEvent(blocksToDiscard.toArray(), EventType.PROVIDER_DATA_REMOVED), false); } // run synchronously for now if (!canceled) threadPool[0].run(); // print debug info if (log.isDebugEnabled()) { //blockLists[0].checkConsistency(); log.debug("Block lists size = " + blockLists[0].getSize() + ", " + blockLists[1].getSize()); //QuadTreeItemCounter counter = new QuadTreeItemCounter(); //quadTree.accept(counter); //System.out.println("quadtree size = " + counter.numItems + " (" // + counter.numItemsWithData + ")"); } }
From source file:org.marketcetera.strategy.StrategyTestBase.java
/** * Creates a strategy with the given parameters. * //from w ww. j a v a 2 s . c o m * <p>The strategy is guaranteed to be running at the successful exit of this method. Strategies created by this method * are tracked and shut down, if necessary, at the end of the test. * * @param inParameters an <code>Object...</code> value containing the parameters to pass to the module creation command * @return a <code>ModuleURN</code> value containing the URN of the strategy * @throws Exception if an error occurs */ protected ModuleURN createStrategy(Object... inParameters) throws Exception { verifyNullProperties(); LinkedList<Object> actualParameters = new LinkedList<Object>(Arrays.asList(inParameters)); if (inParameters.length <= 6) { actualParameters.addFirst(null); } ModuleURN strategyURN = createModule(StrategyModuleFactory.PROVIDER_URN, actualParameters.toArray()); theStrategy = strategyURN; verifyStrategyReady(strategyURN); return strategyURN; }
From source file:com.projity.grouping.core.hierarchy.MutableNodeHierarchy.java
private List internalIndent(List nodes, int deltaLevel, int actionType) { if (deltaLevel != 1 && deltaLevel != -1) return null; //Indent only parents LinkedList nodesToChange = new LinkedList(); HierarchyUtils.extractParents(nodes, nodesToChange); List modifiedVoids = new ArrayList(); //exclude Assignments and VoidNodes if (deltaLevel > 0) { for (ListIterator i = nodesToChange.listIterator(); i.hasNext();) { if (!internalIndent((Node) i.next(), deltaLevel, actionType & NodeModel.UNDO, modifiedVoids)) i.remove();/* w w w .j a va2 s. com*/ for (Iterator j = modifiedVoids.iterator(); j.hasNext();) { i.add(j.next()); } modifiedVoids.clear(); } } else { for (ListIterator i = nodesToChange.listIterator(nodesToChange.size()); i.hasPrevious();) { if (!internalIndent((Node) i.previous(), deltaLevel, actionType & NodeModel.UNDO, modifiedVoids)) i.remove(); for (Iterator j = modifiedVoids.iterator(); j.hasNext();) { i.add(j.next()); } modifiedVoids.clear(); } } if (isEvent(actionType) && nodesToChange.size() > 0) fireNodesChanged(this, nodesToChange.toArray()); return nodesToChange; }