Parses the links attributes from the given source {@link String}.

@param source
@return
979009
private static Map<String, String> getAttributeMap(String source) {

		if (!StringUtils.hasText(source)) {
			return Collections.emptyMap();
		}

		Map<String, String> attributes = new HashMap<>();
		Matcher matcher = KEY_AND_VALUE_PATTERN.matcher(source);

		while (matcher.find()) {
			attributes.put(matcher.group(1), matcher.group(2));
		}

		return attributes;
	}
368286
public static void getTopicLinkIds(final Node node, final Set<String> linkIds) {
        // If the node is null then there isn't anything to find, so just return.
        if (node == null) {
            return;
        }

        if (node.getNodeName().equals("xref") || node.getNodeName().equals("link")) {
            final NamedNodeMap attributes = node.getAttributes();
            if (attributes != null) {
                final Node idAttribute = attributes.getNamedItem("linkend");
                if (idAttribute != null) {
                    final String idAttributeValue = idAttribute.getNodeValue();
                    linkIds.add(idAttributeValue);
                }
            }
        }

        final NodeList elements = node.getChildNodes();
        for (int i = 0; i < elements.getLength(); ++i) {
            getTopicLinkIds(elements.item(i), linkIds);
        }
    }
1187
@Override
    public ParseResult parse(final Source source) {
        return Util.execute(new ExceptionAction<ParseResult>() {
            @Override
            public ParseResult doAction() throws Throwable {
                logger.fine("Parsing " + source.getSrcInfo());
                final BufferedReader reader = source.createReader();
                try {
                    final ParserImpl impl = factory.create(source.getSrcInfo(),
                            reader);
                    final Doc doc = impl.doc();
                    return new ParseResult(doc, impl.errors());
                } finally {
                    reader.close();
                }
            }
        });
    }
106054
public Template parseTemplate(String source, Object parameterTypes) throws ParseException {
        String name = "/$" + Digest.getMD5(source);
        if (!hasResource(name)) {
            stringLoader.add(name, source);
        }
        try {
            return getTemplate(name, parameterTypes);
        } catch (IOException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
477903
public static Element parse(InputSource source) throws IOException
   {
      try
      {
         Document doc;
         DocumentBuilder builder = getDocumentBuilder();
         synchronized (builder) //synchronize to prevent concurrent parsing on the same DocumentBuilder
         {
            doc = builder.parse(source);
         }
         return doc.getDocumentElement();
      }
      catch (SAXException se)
      {
         throw new IOException(se.toString());
      }
      finally
      {
         InputStream is = source.getByteStream();
         if (is != null)
         {
            is.close();
         }
         Reader r = source.getCharacterStream();
         if (r != null)
         {
            r.close();
         }
      }
   }
16491
public static String encodeUrlSafe(String source, String charset) {
		return encodeUrlSafe(StrUtil.bytes(source, charset), charset);
	}
648102
protected static final Object parseList(Source src) throws IOException {
		final LinkedList<Object> list = new LinkedList<Object>();
		boolean foundEnd = false;
		try {
			if (src.ch == '[') {
				src.idx++;
			}
			skipWhitespaces(src);
			if (src.ch == ']') {
				src.idx++;
				return list;
			}
			char c;
			loop: while (src.idx < src.last) {
				list.add(parseNext(src));
				while (true) {
					c = src.chars[src.idx];
					if (c == ',') {
						src.idx++;
						continue loop;
					}
					if (c == ']') {
						foundEnd = true;
						src.idx++;
						break loop;
					}
					if (c <= 32) {
						src.idx++;
						continue;
					}
					break;
				}
				c = src.chars[src.idx];
				if (c == ',') {
					src.idx++;
					continue;
				}
				if (c == ']') {
					src.idx++;
					foundEnd = true;
					break;
				}
				throw new IOException(String.format(
						"Expecting a ',' or a ']', " + " but got ch character of  %s " + " on array idx of %s!",
						(int) c, list.size()));
			}
		} catch (IOException ioCause) {
			throw ioCause;
		} catch (Exception cause) {
			throw new IOException("Issue parsing JSON array!", cause);
		}
		if (!foundEnd) {
			throw new IOException("Did not find end of JSON Array!");
		}
		return list;
	}
1350602
public String process(String source) {
        CharSequence result = process((CharSequence) source);
        if (result instanceof String) {
            return (String) result;
        } else {
            return result.toString();
        }
    }
1138982
public static String escapeLink(String source) {

        if (source == null) {
            return null;
        }
        StringBuffer result = new StringBuffer(source.length() * 2);
        int terminatorIndex;
        for (int i = 0; i < source.length(); ++i) {
            char ch = source.charAt(i);
            switch (ch) {
                case '&':
                    // don't escape already escaped &amps;
                    terminatorIndex = source.indexOf(';', i);
                    if (terminatorIndex > 0) {
                        String substr = source.substring(i + 1, terminatorIndex);
                        if ("amp".equals(substr)) {
                            result.append(ch);
                        } else {
                            result.append("&amp;");
                        }
                    } else {
                        result.append("&amp;");
                    }
                    break;
                default:
                    result.append(ch);
            }
        }
        return new String(result);
    }
48751
public List<Object> listFrom(Object source) throws IOException, JSONObjectException
    {
        if (source instanceof JsonParser) {
            // note: no call to _config(), should come pre-configured
            JsonParser p = _initForReading((JsonParser) source);
            List<Object> result = _readerForOperation(p).readList();
            // Need to consume the token too
            p.clearCurrentToken();
            return result;
        }
        JsonParser p = _parser(source);
        try {
            _initForReading(_config(p));
            List<Object> result = _readerForOperation(p).readList();
            JsonParser p0 = p;
            p = null;
            _close(p0, null);
            return result;
        } catch (Exception e) {
            return _closeWithError(p, e);
        }
    }
1062449
@Override
    public DataByteInput<T> source(final T source) {
        return (DataByteInput<T>) super.source(source);
    }
484256
public static String encode(String source, String charset) {
		return Base64Encoder.encode(source, charset);
	}
737580
private ResourceReference parseDocumentLink(StringBuilder content)
    {
        // Extract any query string.
        String queryString = null;
        String text = parseElementAfterString(content, SEPARATOR_QUERYSTRING);
        if (text != null) {
            queryString = removeEscapesFromExtraParts(text);
        }

        // Extract any anchor.
        String anchor = null;
        text = parseElementAfterString(content, SEPARATOR_ANCHOR);
        if (text != null) {
            anchor = removeEscapesFromExtraParts(text);
        }

        // Make sure to unescape the remaining reference string.
        String unescapedReferenceString = removeEscapesFromReferencePart(content.toString());
        // Parse the string as an untyped link reference.
        ResourceReference reference = untypedLinkReferenceParser.parse(unescapedReferenceString);
        reference.setTyped(false);

        // Set any previously extracted parameters.
        if (StringUtils.isNotBlank(queryString)) {
            reference.setParameter(DocumentResourceReference.QUERY_STRING, queryString);
        }
        if (StringUtils.isNotBlank(anchor)) {
            reference.setParameter(DocumentResourceReference.ANCHOR, anchor);
        }

        return reference;
    }
219669
def read(cls, source):
        
        if hasattr(source, "read"):
            return cls.fromfile(source)
        if os.path.exists(source):
            return cls.fromfile(source)
        if isinstance(source, six.string_types):
            source = source.encode("utf8")
        return cls.fromstring(source)
1113410
public static <T> Set<T> wrapSet(final T... source) {
        val list = new LinkedHashSet<T>();
        addToCollection(list, source);
        return list;
    }
575766
public static <T> Set<T> wrap(final Set<T> source) {
        val list = new LinkedHashSet<T>();
        if (source != null && !source.isEmpty()) {
            list.addAll(source);
        }
        return list;
    }
1308953
public Map<String, String> split(final CharSequence source) {
    java.util.Objects.requireNonNull(source, "source");
    Map<String, String> parameters = new HashMap<>();
    Iterator<String> i = new StringIterator(source, pairSeparator);
    while (i.hasNext()) {
      String keyValue = i.next();

      int keyValueSeparatorPosition = keyValueSeparatorStart(keyValue);
      if (keyValueSeparatorPosition == 0 || keyValue.length() == 0) {
        continue;
      }
      if (keyValueSeparatorPosition < 0) {
        parameters.put(keyValue, null);
        continue;
      }
      int keyStart = 0;
      int keyEnd = keyValueSeparatorPosition;

      while (keyStart < keyEnd && keyTrimMatcher.matches(keyValue.charAt(keyStart))) {
        keyStart++;
      }
      while (keyStart < keyEnd && keyTrimMatcher.matches(keyValue.charAt(keyEnd - 1))) {
        keyEnd--;
      }

      int valueStart = keyValueSeparatorPosition + keyValueSeparator.length();
      int valueEnd = keyValue.length();

      while (valueStart < valueEnd && valueTrimMatcher.matches(keyValue.charAt(valueStart))) {
        valueStart++;
      }
      while (valueStart < valueEnd && valueTrimMatcher.matches(keyValue.charAt(valueEnd - 1))) {
        valueEnd--;
      }

      String key = keyValue.substring(keyStart, keyEnd);
      String value = keyValue.substring(valueStart, valueEnd);
      parameters.put(key, value);
    }
    return parameters;
  }