private Map<String, List<String>> createOtherNames(final String nameText, final String aliases) { currentGeneName = null; final Map<String, List<String>> map = new HashMap<String, List<String>>(); final String[] names = SPLITTER.split(nameText); final String[] others = SPLITTER.split(aliases); final List<String[]> entries = new ArrayList<String[]>(); entries.add(names); entries.add(others); for (final String[] entry : entries) { for (final String name : entry) { final String[] parsed = parseValues(name); List<String> list = map.get(parsed[0]); if (list == null) { list = new ArrayList<String>(); } if (parsed[1] != null) { list.add(parsed[1]); if (parsed[2] != null && parsed[2].equals("gene name")) { currentGeneName = parsed[1]; } } else { continue; } map.put(parsed[0], list); } } return map; }
static Map<String, MatchPair> parseNameAndValueListString2Condition( Map<String, String> params, Map<String, String> notParams) { Map<String, MatchPair> condition = new HashMap<String, RouteRule.MatchPair>(); for (Entry<String, String> entry : params.entrySet()) { String valueListString = entry.getValue(); if (StringUtils.isBlank(valueListString)) { continue; } String[] list = VALUE_LIST_SEPARATOR.split(valueListString); Set<String> set = new HashSet<String>(); for (String item : list) { if (StringUtils.isBlank(item)) { continue; } set.add(item.trim()); } if (set.isEmpty()) { continue; } String key = entry.getKey(); MatchPair matchPair = condition.get(key); if (null == matchPair) { matchPair = new MatchPair(); condition.put(key, matchPair); } matchPair.matches = set; } for (Entry<String, String> entry : notParams.entrySet()) { String valueListString = entry.getValue(); if (StringUtils.isBlank(valueListString)) { continue; } String[] list = VALUE_LIST_SEPARATOR.split(valueListString); Set<String> set = new HashSet<String>(); for (String item : list) { if (StringUtils.isBlank(item)) { continue; } set.add(item.trim()); } if (set.isEmpty()) { continue; } String key = entry.getKey(); MatchPair matchPair = condition.get(key); if (null == matchPair) { matchPair = new MatchPair(); condition.put(key, matchPair); } matchPair.unmatches = set; } return condition; }
public static double[] parseMetaData(String name) { double[] m = new double[3]; String[] s = EQUAL_PATTERN.split(name); m[0] = Double.parseDouble(PIPE_PATTERN.split(s[0])[1]); m[1] = Double.parseDouble(PIPE_PATTERN.split(s[1])[1]); m[2] = Double.parseDouble(s[2].substring(1)); return m; }
private Long parseAndAmount(String amount) { try { Pattern p = getPattern(MatchAnd); String[] array = p.split(amount); if (array != null && array.length > 0) { Long p1 = ("".equals(array[0].trim())) ? 0 : parseDollarsPart(array[0]); boolean lastPosition = array[0].contains("dollar") || p1 < 10000; for (int i = 1; i < array.length; ++i) { Long p2 = null; String s = array[i].trim(); if (i == array.length - 1) { if (s.contains("dollar")) { p = getPattern("dollar"); String[] ar = p.split(s); if (ar.length == 1) { p2 = parseDollarsPart(ar[0]); } else if (ar.length > 1) { p2 = parseDollarsPart(ar[0]); Long p3 = parseCentsPart(ar[1]); p2 = Summary(p2, p3); } } else if (lastPosition || IsMatch("([a-z,0-9,\\s]+)cent[s]?(\\s*)", s) || IsMatch(MatchCents, s)) { p2 = parseCentsPart(s); } else { p2 = parseDollarsPart(s); lastPosition = s.contains("dollar") || (p2 != null && p2 < 10000); } } else { p2 = parseDollarsPart(s); } if (p1 == null || p2 == null) { return getInvalidAmount(); } p1 = Summary(p1, p2); } return p1; } } catch (Exception ex) { System.err.println(ex.getMessage()); } return getInvalidAmount(); }
/** * Resolve class members that were defined using the @property tag * * @param type declaration for wich we add the magic variables */ private void resolveMagicMembers(TypeDeclaration type) { if (type instanceof IPHPDocAwareDeclaration) { final IPHPDocAwareDeclaration declaration = (IPHPDocAwareDeclaration) type; final PHPDocBlock doc = declaration.getPHPDoc(); if (doc != null) { final PHPDocTag[] tags = doc.getTags(); for (final PHPDocTag docTag : tags) { final int tagKind = docTag.getTagKind(); if (tagKind == PHPDocTag.PROPERTY || tagKind == PHPDocTag.PROPERTY_READ || tagKind == PHPDocTag.PROPERTY_WRITE) { // http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.property.pkg.html final String[] split = WHITESPACE_SEPERATOR.split(docTag.getValue().trim()); if (split.length < 2) { break; } final ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo(); info.modifiers = Modifiers.AccPublic; info.name = split[1]; final SimpleReference var = new SimpleReference( docTag.sourceStart(), docTag.sourceStart() + 9, removeParenthesis(split)); info.nameSourceStart = var.sourceStart(); info.nameSourceEnd = var.sourceEnd(); info.declarationStart = info.nameSourceStart; fRequestor.enterField(info); fRequestor.exitField(info.nameSourceEnd); } else if (tagKind == PHPDocTag.METHOD) { // http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.method.pkg.html final String[] split = WHITESPACE_SEPERATOR.split(docTag.getValue().trim()); if (split.length < 2) { break; } final ISourceElementRequestor.MethodInfo mi = new ISourceElementRequestor.MethodInfo(); mi.parameterNames = null; mi.name = removeParenthesis(split); final SimpleReference var = new SimpleReference( docTag.sourceStart(), docTag.sourceStart() + 6, removeParenthesis(split)); mi.modifiers = Modifiers.AccPublic; mi.nameSourceStart = var.sourceStart(); mi.nameSourceEnd = var.sourceEnd(); mi.declarationStart = mi.nameSourceStart; mi.isConstructor = false; this.fRequestor.enterMethod(mi); this.fRequestor.exitMethod(mi.nameSourceEnd); } } } } }
private void handleCookieHeader(String hdr, String value) { if (hdr.equals("Cookie")) { for (String cookie : cookieSeparator.split(value)) { String[] parts = valueSeparator.split(cookie, 2); String cn = parts[0]; String cv = parts.length < 2 || parts[1] == null ? "" : parts[1]; ScriptableObject.putProperty(cookies, cn, cv); } } }
protected int binariesInstance(String line, FeatureList featureList) throws MaltChainedException { int y = -1; featureList.clear(); try { String[] columns = tabPattern.split(line); if (columns.length == 0) { return -1; } try { y = Integer.parseInt(columns[0]); } catch (NumberFormatException e) { throw new LibException( "The instance file contain a non-integer value '" + columns[0] + "'", e); } for (int j = 1; j < columns.length; j++) { final String[] items = pipePattern.split(columns[j]); for (int k = 0; k < items.length; k++) { try { int colon = items[k].indexOf(':'); if (colon == -1) { if (Integer.parseInt(items[k]) != -1) { int v = featureMap.addIndex(j, Integer.parseInt(items[k])); if (v != -1) { featureList.add(v, 1); } } } else { int index = featureMap.addIndex(j, Integer.parseInt(items[k].substring(0, colon))); double value; if (items[k].substring(colon + 1).indexOf('.') != -1) { value = Double.parseDouble(items[k].substring(colon + 1)); } else { value = Integer.parseInt(items[k].substring(colon + 1)); } featureList.add(index, value); } } catch (NumberFormatException e) { throw new LibException( "The instance file contain a non-numeric value '" + items[k] + "'", e); } } } } catch (ArrayIndexOutOfBoundsException e) { throw new LibException("Couln't read from the instance file. ", e); } return y; }
/** * Extract all tables content, and returns a list containing an array for each table, in which * each row is an element: columns and attributes are divided by the delimiters specified in the * constructor * * @param inputText html of the page * @return a list containing an array for each table, in which each row is an element * @see {@link #HtmlTableExtractor()}, {@link #HtmlTableExtractor(String, String)}, {@link * #getDelimiterColumns()}, {@link #getDelimiterAttributes()} */ public List<String[]> extract(String inputText) { // remove line endings and get a tables matcher Matcher tableMatcher = PATTERN_TABLE.matcher(PATTERN_NEW_LINE.matcher(inputText).replaceAll("")); List<String[]> tables = new ArrayList<String[]>(); while (tableMatcher.find()) { String tableHtml = tableMatcher.group(); // the current table // matched // replace usefull attrs prefix tableHtml = PATTERN_USEFULL_ATTRS.matcher(tableHtml).replaceAll(this.delimiterAttributes); // remove useless attributes tableHtml = PATTERN_ALL_ATTRS.matcher(tableHtml).replaceAll(""); // replace first part of the tag containing usefull attribute tableHtml = PATTERN_USEFULL_ATTRS_START.matcher(tableHtml).replaceAll(this.delimiterAttributes); // replace last part of the tag containing usefull attribute tableHtml = PATTERN_USEFULL_ATTRS_END.matcher(tableHtml).replaceAll(this.delimiterAttributes); // split table rows on different lines tableHtml = PATTERN_TABLE_ROW_END_TAG.matcher(tableHtml).replaceAll("\n"); // replace column end tag with field separator tableHtml = PATTERN_TABLE_COLUMN_END_TAG.matcher(tableHtml).replaceAll(this.delimiterColumns); // remove all other tags tableHtml = PATTERN_ALL_EMPTY_TAGS.matcher(tableHtml).replaceAll(""); // add the current table (each row is a element of the array) to the // tables list tables.add(PATTERN_NEW_LINE.split(tableHtml)); } return tables; }
private String doCommands(String key, Link source) { String[] args = commands.split(key); if (args == null || args.length == 0) return null; for (int i = 0; i < args.length; i++) if (args[i].indexOf('\\') >= 0) args[i] = args[i].replaceAll("\\\\;", ";"); if (args[0].startsWith("^")) { String varname = args[0].substring(1).trim(); Processor parent = source.start.getParent(); if (parent != null) return parent.getProperty(varname); return null; } Processor rover = domain; while (rover != null) { String result = doCommand(rover, args[0], args); if (result != null) return result; rover = rover.getParent(); } for (int i = 0; targets != null && i < targets.length; i++) { String result = doCommand(targets[i], args[0], args); if (result != null) return result; } return doCommand(this, args[0], args); }
@RequestMapping(value = "/{instancename}/top-questions/{taglist}", method = RequestMethod.GET) public String topQuestions( @PathVariable("instancename") String instanceName, @RequestParam(required = false) Integer type, @RequestParam(required = false) Integer when, @PathVariable("taglist") String tagList, HttpServletRequest request) { if (type == null) { type = QuestionServiceImpl.TYPE_VIEWS; } if (when == null) { when = QuestionServiceImpl.WHEN_MONTH; } request.setAttribute("type", type); request.setAttribute("when", when); Instance instance = putInstanceInRequest(instanceName, request); putUserInRequest(request); Collection<Question> questions; if (tagList == null) { questions = questionService.showTopQuestions(instance.getId(), type, when); } else { request.setAttribute("selectedTagsList", tagList); String[] selTagsArray = tagSplitter.split(tagList); Arrays.sort(selTagsArray); questions = questionService.showTopQuestions(instance.getId(), type, when, selTagsArray); } request.setAttribute("questions", questions); return "top-questions"; }
public static void main(String[] args) { Pattern p = Pattern.compile(":"); Matcher m = p.matcher(""); for (String string : p.split("boo:and:foo", 2)) { System.out.println(string); } }
private MyBooleanExpression(String expression) throws ParseException { expression = expression.replaceAll(" ", "").replaceAll("!", "~"); this.repr = expression; Pattern pattern = Pattern.compile("[()~&|=>+]"); String[] vars = pattern.split(expression); HashSet<String> varsSet = new HashSet<>(Arrays.asList(vars)); varsSet.removeAll(Arrays.asList(new String[] {"", "1", "0"})); this.variables = varsSet.toArray(new String[0]); assert variables.length < 26; String shortExpr = new String(expression); for (int i = 0; i < variables.length; i++) { shortExpr = shortExpr.replaceAll(variables[i], "___" + i); } for (int i = 0; i < variables.length; i++) { shortExpr = shortExpr.replaceAll("___" + i, "" + (char) ('a' + i)); } // System.out.println(shortExpr); BooleanExpression booleanExpression = new BooleanExpression(shortExpr); Map<Map<String, Boolean>, Map<BooleanExpression, Boolean>> truthTable = new TruthTable(booleanExpression).getResults(); this.truthTable = new HashMap<>(); for (Map<String, Boolean> map : truthTable.keySet()) { Map<BooleanExpression, Boolean> booleanMap = truthTable.get(map); boolean val = booleanMap.containsValue(true); satisfiabilitySetsCount += val ? 1 : 0; this.truthTable.put(map, val); } }
public static ItemFilter parse(String filter, Locale locale, IItemFilter filterCard) { ArrayList<ItemFilter> list = new ArrayList<ItemFilter>(); if (filterCard != null) { list.add(new CardFilter(filterCard)); } String[] parts = SPLIT_PATTERN.split(filter); for (String part : parts) { if (part.startsWith("@")) { part = part.substring(1); if (!part.isEmpty()) { list.add(new ModFilter(part, locale)); } } else if (!part.isEmpty()) { list.add(new NameFilter(part, locale)); } } if (list.isEmpty()) { return null; } if (list.size() == 1) { return list.get(0); } return new AndFilter(list.toArray(new ItemFilter[list.size()])); }
public String getDetailedErrorDescription() { if (Utils.currentPage().contains("SPD")) { String[] split = ID_DELIMITER.split(fieldId); if (split.length == 2) { String pdId = split[1]; return Utils.translate("PD") + ' ' + pdId + " - " + fieldTitle + " : " + facesMessageTexts.get(0).getErrorText(); } else { return facesMessageTexts.get(0).getErrorText(); } } if (tableName != null && !tableName.isEmpty()) { String rowIndex = Integer.toString(rowId + 1); return Utils.translate("row") + ' ' + rowIndex + " - " + fieldTitle + " : " + facesMessageTexts.get(0).getErrorText(); } if (fieldTitle != null) { return fieldTitle + " : " + facesMessageTexts.get(0).getErrorText(); } return facesMessageTexts.get(0).getErrorText(); }
@Override public Object convert(String value) { if (value == null || value.isEmpty()) { return value; } Map<String, String> fields = Maps.newHashMap(); if (value.contains("=")) { final String nmsg = kvPattern.matcher(value).replaceAll("="); if (nmsg.contains("=\"")) { Matcher m = quotedValuePattern.matcher(nmsg); while (m.find()) { String[] kv = m.group(1).split("="); if (kv.length == 2 && p.matcher(kv[0]).matches()) { fields.put(kv[0].trim(), QUOTE_MATCHER.removeFrom(kv[1]).trim()); } } } else { final String[] parts = spacePattern.split(nmsg); if (parts != null) { for (String part : parts) { if (part.contains("=") && EQUAL_SIGN_MATCHER.countIn(part) == 1) { String[] kv = part.split("="); if (kv.length == 2 && p.matcher(kv[0]).matches() && !fields.containsKey(kv[0])) { fields.put(kv[0].trim(), kv[1].trim()); } } } } } } return fields; }
public Instance createInstance(String line) throws NumberFormatException { StringTokenizer st = new StringTokenizer(line, " \t"); if (!st.hasMoreTokens()) { throw new RuntimeException("Lable not Found"); } String labelStr = st.nextToken(); boolean label = false; if (labelStr.equals("+1")) label = true; ArrayList<Float> weightslist = new ArrayList<Float>(); ArrayList<Integer> indiceslist = new ArrayList<Integer>(); while (st.hasMoreTokens()) { String[] kv = spliter.split(st.nextToken()); if (kv.length != 2) { throw new RuntimeException("Cannot parse line " + line); } indiceslist.add(new Integer(kv[0])); weightslist.add(new Float(kv[1])); } int[] indices = new int[indiceslist.size()]; float[] weights = new float[weightslist.size()]; for (int i = 0; i < indices.length; ++i) { indices[i] = indiceslist.get(i).intValue(); weights[i] = weightslist.get(i).floatValue(); } return new Instance(weights, indices, label); }
protected static String[] getChanceSplit(String str) { if (str == null) return null; String[] split = chanceSplit.split(str); return split.length == 2 ? split : null; }
public void connect() throws IOException { if (!connected) { String path = url.getPath(); Matcher matcher = urlPattern.matcher(path); if (matcher.matches()) { path = matcher.group(1); String subPath = matcher.group(2); JarURLConnection jarURLConnection = (JarURLConnection) new URL("jar:" + path).openConnection(); inputStream = jarURLConnection.getInputStream(); if (subPath.isEmpty() == false) { JarFile jar = retrieve(new URL(path), inputStream); String[] nodes = nestingSeparatorPattern.split(subPath); int i; for (i = 0; i < nodes.length - 1; i++) { path += "!/" + nodes[i]; jar = retrieve(new URL(path), inputStream); } ZipEntry entry = jar.getEntry(nodes[i]); entrySize = entry.getSize(); inputStream = jar.getInputStream(entry); } } else { throw new MalformedURLException("Invalid JAP URL path: " + path); } connected = true; } }
@Override public Operation decodeEvent(String[] csvRow) { long scheduledStartTimeAsMilli = Long.parseLong(csvRow[0]); long dependencyTimeAsMilli = Long.parseLong(csvRow[1]); long forumId = Long.parseLong(csvRow[3]); String forumTitle = csvRow[4]; String creationDateString = csvRow[5]; Date creationDate = new Date(Long.parseLong(creationDateString)); long moderatorPersonId = Long.parseLong(csvRow[6]); String tagIdsAsString = csvRow[7]; List<Long> tagIds = new ArrayList<>(); if (false == tagIdsAsString.isEmpty()) { String[] tagIdsAsStrings = collectionSeparatorPattern.split(tagIdsAsString, -1); for (String tagId : tagIdsAsStrings) { tagIds.add(Long.parseLong(tagId)); } } Operation operation = new LdbcUpdate4AddForum(forumId, forumTitle, creationDate, moderatorPersonId, tagIds); operation.setScheduledStartTimeAsMilli(scheduledStartTimeAsMilli); operation.setTimeStamp(scheduledStartTimeAsMilli); operation.setDependencyTimeStamp(dependencyTimeAsMilli); return operation; }
/** * Returns the sorted names of all available databases and, optionally, backups. Filters for * {@code name} if not {@code null} with glob support. * * @param db return databases? * @param backup return backups? * @param name name filter (may be {@code null}) * @return database and backups list */ private StringList list(final boolean db, final boolean backup, final String name) { final Pattern pt; if (name != null) { final String nm = REGEX.matcher(name).matches() ? IOFile.regex(name) : name.replaceAll("([" + REGEXCHARS + "])", "\\\\$1"); pt = Pattern.compile(nm, Prop.CASE ? 0 : Pattern.CASE_INSENSITIVE); } else { pt = null; } final IOFile[] children = soptions.dbpath().children(); final StringList list = new StringList(children.length); final HashSet<String> map = new HashSet<>(children.length); for (final IOFile f : children) { final String fn = f.name(); String add = null; if (backup && fn.endsWith(IO.ZIPSUFFIX)) { final String nn = ZIPPATTERN.split(fn)[0]; if (!nn.equals(fn)) add = nn; } else if (db && f.isDir() && fn.indexOf('.') == -1) { add = fn; } // add entry if it matches the pattern, and has not already been added if (add != null && (pt == null || pt.matcher(add).matches()) && map.add(add)) { list.add(add); } } return list.sort(false); }
private int readNestedPosition(String fieldName, FieldType type) throws IOException { String[] fieldNames = NESTED_FIELD_PATTERN.split(fieldName); if (fieldNames.length > 1) { FieldDefinition fd = null; DefaultPortableReader reader = this; for (int i = 0; i < fieldNames.length; i++) { fd = reader.cd.getField(fieldNames[i]); if (fd == null) { break; } if (i == fieldNames.length - 1) { break; } int pos = reader.readPosition(fd); in.position(pos); boolean isNull = in.readBoolean(); if (isNull) { throw new NullPointerException("Parent field is null: " + fieldNames[i]); } reader = serializer.createReader(in, fd.getFactoryId(), fd.getClassId(), fd.getVersion()); } if (fd == null) { throw throwUnknownFieldException(fieldName); } if (fd.getType() != type) { throw new HazelcastSerializationException("Not a '" + type + "' field: " + fieldName); } return reader.readPosition(fd); } throw throwUnknownFieldException(fieldName); }
/* (non-Javadoc) * @see org.jasig.portal.portlet.registry.IPortletWindowRegistry#getPortletWindowId(java.lang.String) */ @Override public PortletWindowIdImpl getPortletWindowId( HttpServletRequest request, String portletWindowId) { Validate.notNull(portletWindowId, "portletWindowId can not be null"); final String[] portletWindowIdParts = ID_PART_SEPERATOR_PATTERN.split(portletWindowId); final String entityIdStr; final String instanceId; if (portletWindowIdParts.length == 1) { entityIdStr = portletWindowIdParts[0]; instanceId = null; } else if (portletWindowIdParts.length == 2) { entityIdStr = portletWindowIdParts[0]; instanceId = portletWindowIdParts[1]; } else { throw new IllegalArgumentException( "Provided portlet window ID '" + portletWindowId + "' is not valid"); } final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, entityIdStr); if (portletEntity == null) { throw new IllegalArgumentException( "No parent IPortletEntity found for id '" + entityIdStr + "' from portlet window id: " + portletWindowId); } return createPortletWindowId(instanceId, portletEntity.getPortletEntityId()); }
public static void main(String[] args) { Scanner reader = new Scanner(System.in); Pattern p = Pattern.compile("\\s{1,}"); Pattern p1 = Pattern.compile( "[\\+\\-][0-9]*[xX]\\^[0-9]*|[\\+\\-][0-9]*\\*[xX]\\^[0-9]*|[0-9]*[xX]\\^[0-9]*|[\\+\\-][0-9]*|[0-9]*\\*[xX]\\^[0-9]*"); String[] a = p.split(reader.nextLine()); Node[] linkhead = new Node[a.length]; for (int i = 0; i < a.length; i++) { Matcher matcher = p1.matcher(a[i]); // 正则匹配空格分离多个多项式 int counter = 0; while (matcher.find()) { Node temp = convert(matcher.group()); // 依次读取系数和指数 if (counter == 0) { linkhead[i] = temp; counter++; } else { linkhead[i] = ordersort(linkhead[i], temp); // 排序并把各个多项式的链表头分别储存 counter++; } } } Node sumhead = add(linkhead); // 将各个多项式相加 showit(sumhead); }
private Long parseCentsPart(String amount) { amount = amount.replaceAll(Cents, ""); amount = RemoveMiddleSpaceInNumber(amount); if ("".equals(amount)) { return getInvalidAmount(); } Pattern p = getPattern("/"); String[] array = p.split(amount); if (array != null && array.length > 0) { if (IsMatch("[\\d,\\s]+(\\s)*", array[0])) { return tryParseNumber(array[0]); } else { Long cents = parseNumberInWords(RemoveDollars(array[0])); if (cents != null) { if (cents < 0) { return getInvalidAmount(); } else { cents /= 100; // it is cents } } return cents; } } return getInvalidAmount(); }
// convert string to double // assumes either integer or fractional entries // does not handle entries with decimal point private double stringToDouble(String s) { double n = 999.999; String[] sFraction; int num; int den; try // process integer { n = (double) Integer.parseInt(s); } catch (NumberFormatException nfe) // process fraction { Pattern pat = Pattern.compile("/"); Matcher m = pat.matcher(s); if (m.find()) // fractional input { sFraction = pat.split(s); num = Integer.parseInt(sFraction[0]); den = Integer.parseInt(sFraction[1]); n = ((double) num) / ((double) den); } } return n; }
@Override public Vertex<LongWritable, LongWritable, LongWritable> getCurrentVertex() throws IOException, InterruptedException { Vertex<LongWritable, LongWritable, LongWritable> vertex = conf.createVertex(); String tokens[] = saperator.split(getRecordReader().getCurrentValue().toString()); List<Edge<LongWritable, LongWritable>> edges = Lists.newArrayListWithCapacity(tokens.length - 1); long weight = ((long) 1.0) / (tokens.length - 1); LongWritable VertexId = new LongWritable(Long.parseLong(tokens[0])); LongWritable VertexValue = new LongWritable(Long.parseLong(tokens[1])); System.out.println(VertexValue); String edgeId[] = tokens[2].split(","); /* for(int n=2;n<tokens.length-1;n++) { edges.add(EdgeFactory.create(new LongWritable(Long.parseLong(tokens[n])),new LongWritable(weight))); } */ for (String edge : edgeId) { edges.add( EdgeFactory.create(new LongWritable(Long.parseLong(edge)), new LongWritable(weight))); } // vertex.initialize(VertexId, (LongWritable) edges); vertex.initialize(VertexId, VertexValue, edges); return vertex; }
static Set<BarcodeFormat> parseDecodeFormats(Uri inputUri) { List<String> formats = inputUri.getQueryParameters(QRcodeIntents.Scan.FORMATS); if (formats != null && formats.size() == 1 && formats.get(0) != null) { formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0))); } return parseDecodeFormats(formats, inputUri.getQueryParameter(QRcodeIntents.Scan.MODE)); }
private List<Qualifier> strToQualifiers(String str) { String[] qus = qStrSplit.split(str); List<Qualifier> res = new ArrayList<>(qus.length); for (String s : qus) { s = unescQS.matcher(s).replaceAll(QUALIFIERS_SEPARATOR); String nm = s; String vl = null; int pos = 0; while (pos < s.length() && (pos = s.indexOf(QUALIFIER_VALUE_SEPARATOR, pos)) != -1) { if (pos == 0) break; if (s.charAt(pos - 1) != '\\') { nm = unescQV.matcher(s.substring(0, pos)).replaceAll(QUALIFIER_VALUE_SEPARATOR); vl = s.substring(pos + QUALIFIER_VALUE_SEPARATOR.length()); break; } pos = pos + QUALIFIER_VALUE_SEPARATOR.length(); } res.add(new Qualifier(nm, vl)); } return res; }
public static String collectStats(CharSequence flattenedParams) { StringBuilder result = new StringBuilder(1000); result.append("BOARD=").append(Build.BOARD).append('\n'); result.append("BRAND=").append(Build.BRAND).append('\n'); result.append("CPU_ABI=").append(Build.CPU_ABI).append('\n'); result.append("DEVICE=").append(Build.DEVICE).append('\n'); result.append("DISPLAY=").append(Build.DISPLAY).append('\n'); result.append("FINGERPRINT=").append(Build.FINGERPRINT).append('\n'); result.append("HOST=").append(Build.HOST).append('\n'); result.append("ID=").append(Build.ID).append('\n'); result.append("MANUFACTURER=").append(Build.MANUFACTURER).append('\n'); result.append("MODEL=").append(Build.MODEL).append('\n'); result.append("PRODUCT=").append(Build.PRODUCT).append('\n'); result.append("TAGS=").append(Build.TAGS).append('\n'); result.append("TIME=").append(Build.TIME).append('\n'); result.append("TYPE=").append(Build.TYPE).append('\n'); result.append("USER="******"VERSION.CODENAME=").append(Build.VERSION.CODENAME).append('\n'); result.append("VERSION.INCREMENTAL=").append(Build.VERSION.INCREMENTAL).append('\n'); result.append("VERSION.RELEASE=").append(Build.VERSION.RELEASE).append('\n'); result.append("VERSION.SDK_INT=").append(Build.VERSION.SDK_INT).append('\n'); if (flattenedParams != null) { String[] params = SEMICOLON.split(flattenedParams); Arrays.sort(params); for (String param : params) { result.append(param).append('\n'); } } return result.toString(); }
protected void addNodes( Integer graphId, Connection con, ContainerLoader cl, Map<String, Object> graphParam) throws SQLException { String urlbaseTmp = (String) graphParam.get("url_base"); final ElementDraft.Factory elementDraftFactory = cl.factory(); final Pattern tagSplitter = Pattern.compile(","); final String urlbase = urlbaseTmp == null ? "/" : urlbaseTmp; graphDataSource.populateNodesForGraph( con, graphId, (num, name, tag) -> { String[] tags = tag != null ? tagSplitter.split(tag) : new String[] {}; NodeDraft nd = elementDraftFactory.newNodeDraft(num.toString()); nd.setLabel(name); nd.setValue(KEY_URL, urlbase + num); nd.setValue(KEY_TAG, tags); cl.addNode(nd); return true; }); }