List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:de.vanita5.twittnuker.util.net.ssl.AbstractCheckSignatureVerifier.java
/** * Extracts the array of SubjectAlt DNS or IP names from an X509Certificate. * Returns null if there aren't any./*from w w w. j ava 2 s .c o m*/ * * @param cert X509Certificate * @param hostname * @return Array of SubjectALT DNS or IP names stored in the certificate. */ private static String[] getSubjectAlts(final X509Certificate cert, final String hostname) { final int subjectType; if (isIPAddress(hostname)) { subjectType = 7; } else { subjectType = 2; } final LinkedList<String> subjectAltList = new LinkedList<String>(); Collection<List<?>> c = null; try { c = cert.getSubjectAlternativeNames(); } catch (final CertificateParsingException cpe) { } if (c != null) { for (final List<?> aC : c) { final List<?> list = aC; final int type = ((Integer) list.get(0)).intValue(); if (type == subjectType) { final String s = (String) list.get(1); subjectAltList.add(s); } } } if (!subjectAltList.isEmpty()) { final String[] subjectAlts = new String[subjectAltList.size()]; subjectAltList.toArray(subjectAlts); return subjectAlts; } else return null; }
From source file:com.github.lindenb.jvarkit.util.vcf.VCFUtils.java
public static CodecAndHeader parseHeader(LineIterator r) { CodecAndHeader vh = new CodecAndHeader(); vh.codec = null;//from w ww . ja v a 2 s. c o m LinkedList<String> stack = new LinkedList<String>(); while (r.hasNext()) { String line = r.peek(); if (!line.startsWith("#")) break; stack.add(r.next()); if (line.startsWith("#CHROM\t")) break; } vh.codec = findCodecFromLines(stack); vh.header = (VCFHeader) vh.codec.readActualHeader(new LIT(stack)); return vh; }
From source file:org.zywx.wbpalmstar.plugin.uexiconlist.utils.IconListUtils.java
public static LinkedList<IconBean> parseIconBeanList(String jsonArryStr) { LinkedList<IconBean> iconList = null; if (!TextUtils.isEmpty(jsonArryStr)) { iconList = new LinkedList<IconBean>(); try {/*from w ww. j av a2 s . c om*/ JSONObject json = new JSONObject(jsonArryStr); JSONArray jsonArray = json.getJSONArray(JK_LIST_ITEM); if ((jsonArray != null) && (jsonArray.length() > 0)) { for (int i = 0, size = jsonArray.length(); i < size; i++) { JSONObject jsonItem = jsonArray.getJSONObject(i); iconList.add(parseIconBean(jsonItem)); } } } catch (JSONException e) { e.printStackTrace(); } } return iconList; }
From source file:com.epam.reportportal.apache.http.conn.ssl.AbstractVerifier.java
/** * Extracts the array of SubjectAlt DNS or IP names from an X509Certificate. * Returns null if there aren't any.//from w w w .ja v a2s.c om * * @param cert X509Certificate * @param hostname * @return Array of SubjectALT DNS or IP names stored in the certificate. */ private static String[] getSubjectAlts(final X509Certificate cert, final String hostname) { final int subjectType; if (isIPAddress(hostname)) { subjectType = 7; } else { subjectType = 2; } final LinkedList<String> subjectAltList = new LinkedList<String>(); Collection<List<?>> c = null; try { c = cert.getSubjectAlternativeNames(); } catch (final CertificateParsingException cpe) { } if (c != null) { for (final List<?> aC : c) { final List<?> list = aC; final int type = ((Integer) list.get(0)).intValue(); if (type == subjectType) { final String s = (String) list.get(1); subjectAltList.add(s); } } } if (!subjectAltList.isEmpty()) { final String[] subjectAlts = new String[subjectAltList.size()]; subjectAltList.toArray(subjectAlts); return subjectAlts; } else { return null; } }
From source file:com.cloud.agent.resource.virtualnetwork.ConfigHelper.java
private static List<ConfigItem> generateConfig(SavePasswordCommand cmd) { LinkedList<ConfigItem> cfg = new LinkedList<>(); final String password = cmd.getPassword(); final String vmIpAddress = cmd.getVmIpAddress(); String args = "-v " + vmIpAddress; args += " -p " + password; cfg.add(new ScriptConfigItem(VRScripts.PASSWORD, args)); return cfg;/*from w w w.j a v a 2 s . co m*/ }
From source file:com.att.nsa.mr.client.impl.MRConsumerImpl.java
public static List<String> stringToList(String str) { final LinkedList<String> set = new LinkedList<String>(); if (str != null) { final String[] parts = str.trim().split(","); for (String part : parts) { final String trimmed = part.trim(); if (trimmed.length() > 0) { set.add(trimmed); }/*from w w w.j a va2 s . c om*/ } } return set; }
From source file:com.mirth.connect.client.ui.components.MirthTree.java
/** * Construct a path for a specific node. * // w w w . ja va 2 s . c om * @param parent * @param prefix * @param suffix * @return */ public static StringBuilder constructPath(TreeNode parent, String prefix, String suffix) { StringBuilder sb = new StringBuilder(); sb.insert(0, prefix); MirthTreeNode node = (MirthTreeNode) parent; SerializationType serializationType = node.getSerializationType(); // Get the parent if the leaf was actually passed in instead of the parent. if (node.isLeaf()) { node = (MirthTreeNode) node.getParent(); } /* * MIRTH-3196 - We now assign nodes types as we iterate from child to parent to add more * versatility to namespace drag and drop. The drag and drop can drag nodes, attribute or * namespace attributes so the user should be able to correctly do these now. If a node has * a namespace then will wildcard it. If an ancestor of the node has an implicit namespace * then we will also append a wildcard. The only exception to this is if the implicit * namespace is on the root node, we actually set this to the default namespace in * JavaScriptBuilder. */ LinkedList<PathNode> nodeQ = new LinkedList<PathNode>(); while (node != null && node.getParent() != null) { if (serializationType.equals(SerializationType.JSON) && node.isArrayElement()) { nodeQ.add(new PathNode(String.valueOf(node.getParent().getIndex(node) - 1), PathNode.NodeType.ARRAY_CHILD)); } else { PathNode.NodeType type = PathNode.NodeType.OTHER; if (serializationType.equals(SerializationType.XML)) { type = getXmlNodeType(node); } String nodeValue = node.getValue().replaceAll(" \\(.*\\)", ""); nodeQ.add(new PathNode(nodeValue, type)); if (serializationType.equals(SerializationType.XML)) { int parentIndexValue = getIndexOfNode(node); if (parentIndexValue != -1) { nodeQ.add(nodeQ.size() - 1, new PathNode(String.valueOf(parentIndexValue), PathNode.NodeType.ARRAY_CHILD)); } } } node = (MirthTreeNode) node.getParent(); } boolean foundImplicitNamespace = false; while (!nodeQ.isEmpty()) { PathNode nodeValue = nodeQ.removeLast(); //We start at the parent so if any implicit namespaces are reached then the rest of the nodes should wildcard the namespace boolean includeNamespace = false; PathNode.NodeType type = nodeValue.getType(); //We don't want to include a wildcard for attributes, ns definitions or array indices if (serializationType.equals(SerializationType.XML) && !Arrays .asList(PathNode.NodeType.XML_ATTRIBUTE, PathNode.NodeType.XMLNS_DEFINITION, PathNode.NodeType.XML_PREFIX_DEFINITION, PathNode.NodeType.ARRAY_CHILD) .contains(type)) { if (foundImplicitNamespace) { includeNamespace = true; } else if (type == PathNode.NodeType.XML_XMLNS_NODE) { foundImplicitNamespace = true; includeNamespace = true; } else if (type == PathNode.NodeType.XML_PREFIXED_NODE) { includeNamespace = true; } } if (includeNamespace) { int colonIndex = nodeValue.getValue().indexOf(':') + 1; sb.append(".*::['" + StringUtils.substring(nodeValue.getValue(), colonIndex) + "']"); } else if (serializationType.equals(SerializationType.XML) && type == PathNode.NodeType.XMLNS_DEFINITION) { sb.append(".namespace('')"); } else if (serializationType.equals(SerializationType.XML) && type == PathNode.NodeType.XML_PREFIX_DEFINITION) { sb.append(".namespace('" + StringUtils.substringAfter(nodeValue.getValue(), "@xmlns:") + "')"); } else if (type == PathNode.NodeType.XML_PREFIXED_ATTRIBUTE) { sb.append(".@*::['" + StringUtils.substringAfter(nodeValue.getValue(), ":") + "']"); } else if (type == PathNode.NodeType.ARRAY_CHILD) { sb.append("[" + nodeValue.getValue() + "]"); } else { sb.append("['" + nodeValue.getValue() + "']"); } } if (!serializationType.equals(SerializationType.JSON)) { sb.append(suffix); } return sb; }
From source file:eulermind.importer.LineNode.java
private static LineNode reduceToChapterTreeByBlankLine(List<LineNode> lineNodes) { LinkedList<LineNode> newlineNodes = new LinkedList<LineNode>(); //??, /*from w w w.j a v a 2s . co m*/ for (LineNode lineNode : lineNodes) { if (lineNode.m_blankLines > 200) { lineNode.m_blankLines = 200; } } Iterator<LineNode> iterator = lineNodes.iterator(); newlineNodes.add(iterator.next()); //lineNode ?????newLineNodes // //????? { int maxBlankLines = 0; while (iterator.hasNext()) { LineNode lineNode = iterator.next(); maxBlankLines = Math.max(maxBlankLines, lineNode.m_blankLines); // for (int i = newlineNodes.peekLast().m_blankLines + 1; i < lineNode.m_blankLines; i++) { newlineNodes.add(new LineNode(i)); } newlineNodes.add(lineNode); } // for (int i = newlineNodes.peekLast().m_blankLines + 1; i <= maxBlankLines + 1; i++) { newlineNodes.add(new LineNode(i)); } } //? LinkedList<LineNode> stack = new LinkedList<LineNode>(); for (LineNode newLineNode : newlineNodes) { if (!stack.isEmpty() && stack.peekLast().m_blankLines < newLineNode.m_blankLines) { List<LineNode> reducedLineNodes = popSameBlankLineNodes(stack); for (LineNode reducedLineNode : reducedLineNodes) { newLineNode.add(reducedLineNode); } } stack.add(newLineNode); } assert stack.size() == 1; return stack.peekFirst(); }
From source file:com.cloud.agent.resource.virtualnetwork.ConfigHelper.java
private static List<ConfigItem> generateConfig(SetSourceNatCommand cmd) { LinkedList<ConfigItem> cfg = new LinkedList<>(); IpAddressTO pubIP = cmd.getIpAddress(); String dev = "eth" + pubIP.getNicDevId(); String args = "-A"; args += " -l "; args += pubIP.getPublicIp();/*from w w w.jav a 2 s .c om*/ args += " -c "; args += dev; cfg.add(new ScriptConfigItem(VRScripts.VPC_SOURCE_NAT, args)); return cfg; }
From source file:org.cocos2dx.lib.Cocos2dxBitmap.java
private static String[] splitString(String content, int maxHeight, int maxWidth, Paint paint) { String[] lines = content.split("\\n"); String[] ret = null;//from w w w .j a v a2 s . c o m FontMetricsInt fm = paint.getFontMetricsInt(); int heightPerLine = (int) Math.ceil(fm.bottom - fm.top); int maxLines = maxHeight / heightPerLine; if (maxWidth != 0) { LinkedList<String> strList = new LinkedList<String>(); for (String line : lines) { /* * The width of line is exceed maxWidth, should divide it into * two or more lines. */ int lineWidth = (int) Math.ceil(paint.measureText(line)); if (lineWidth > maxWidth) { strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth)); } else { strList.add(line); } /* * Should not exceed the max height; */ if (maxLines > 0 && strList.size() >= maxLines) { break; } } /* * Remove exceeding lines */ if (maxLines > 0 && strList.size() > maxLines) { while (strList.size() > maxLines) { strList.removeLast(); } } ret = new String[strList.size()]; strList.toArray(ret); } else if (maxHeight != 0 && lines.length > maxLines) { /* * Remove exceeding lines */ LinkedList<String> strList = new LinkedList<String>(); for (int i = 0; i < maxLines; i++) { strList.add(lines[i]); } ret = new String[strList.size()]; strList.toArray(ret); } else { ret = lines; } return ret; }