Tabnine Logo
XMLSource.substring
Code IndexAdd Tabnine to your IDE (free)

How to use
substring
method
in
de.pdark.decentxml.XMLSource

Best Java code snippets using de.pdark.decentxml.XMLSource.substring (Showing top 9 results out of 315)

origin: de.pdark/decentxml

private void expect (XMLSource source, int pos, String expected)
{
  int end = Math.min (pos + expected.length (), source.length ());
  String s = source.substring (pos, end);
  if (!expected.equals (s))
    throw new XMLParseException ("Expected '"+expected+"' but found '"+s+"'", source, pos);
}
 
origin: de.pdark/decentxml

protected void nextChars (String expected, int startPos, String errorMessage)
{
  int len = expected.length () - (pos - startPos);
  if (pos + len > source.length ())
    throw new XMLParseException (errorMessage, source, startPos);
  
  String s = source.substring (startPos, startPos + expected.length ());
  if (!expected.equals (s))
    throw new XMLParseException (errorMessage, source, startPos);
  
  pos += len;
}
origin: de.pdark/decentxml

/**
 * Verify an entity. If no entityResolver is installed, this does nothing.
 */
protected void verifyEntity (int start, int end)
{
  if (entityResolver == null)
    return;
  
  String entity = source.substring (start, end);
  try
  {
    entityResolver.validateEntity (entity);
  }
  catch (IllegalArgumentException e)
  {
    throw new XMLParseException (e.getMessage (), e).setSource (source, start);
  }
}
 
origin: de.pdark/decentxml

  public String getPrefixWhiteSpace ()
  {
    int pos = getStartOffset ();
    int N = getEndOffset ();
    while (pos < N)
    {
      char c = source.charAt (pos);
      if (!Character.isWhitespace (c))
        break;
      pos ++;
    }
    return pos == 0 ? "" : source.substring (getStartOffset (), pos);
  }
}
origin: de.pdark/decentxml

protected String lookAheadForErrorMessage (String conditionalPrefix, int pos, int len)
{
  String found = "";
  if (pos < source.length ())
  {
    int len2 = source.length () - pos;
    len = Math.min (len, len2);
    String s = source.substring (pos, pos+len);
    if (len != len2)
      s += "...";
    if (conditionalPrefix == null)
      found = TextUtils.escapeJavaString (s);
    else
      found = " " + conditionalPrefix + " " + TextUtils.escapeJavaString (s);
  }
  return found;
}
origin: de.pdark/decentxml

/** Return the string of text which this token represents in the XMLSource
 *
 * @return the text or <code>null</code> if there is no source
 */
public String getText ()
{
  return getSource() == null ? null : getSource().substring (getStartOffset(), getEndOffset());
}

origin: de.pdark/decentxml

protected void parseDocTypeText (Token token)
{
  token.setType (Type.TEXT);
  pos --;
  while (pos < source.length () && getCharValidator ().isNameChar (source.charAt (pos)))
    pos ++;
  
  String s = source.substring (token.getStartOffset (), pos);
  if (s.length () == 0)
    throw new XMLParseException ("Expected some text"+lookAheadForErrorMessage ("but found", token.getStartOffset (), 20), token);
  
  // TODO How about "<!DOCTYPE SYSTEM ..."?
  if ("SYSTEM".equals (s))
    token.setType (Type.DOCTYPE_SYSTEM);
  else if ("PUBLIC".equals (s))
    token.setType (Type.DOCTYPE_PUBLIC);
  else if ("NDATA".equals (s))
    token.setType (Type.DOCTYPE_NDATA);
}
origin: de.pdark/decentxml

s = source.substring (errorOffset, pos2);
origin: de.pdark/decentxml

protected void parseDocTypeSubElement (XMLTokenizer tokenizer, Token startToken,
    DocType docType)
{
  Token token = startToken;
  token = expect (tokenizer, token, Type.DTD_WHITESPACE, "Expected whitespace after '<!ELEMENT'");
  token = expect (tokenizer, token, Type.TEXT, "Expected element name");
  String name = token.getText ();
  
  token = expect (tokenizer, token, Type.DTD_WHITESPACE, "Expected whitespace after element name");
  Token beforeContent = token;
  
  while ((token = tokenizer.next ()) != null)
  {
    //System.out.println ("parseDocTypeSubElement "+token);
    if (token.getType() == Type.DOCTYPE_END)
      break;
    
    // TODO Check EMPTY, ANY, #PCDATA, (|), ?, *, +
  }
  if (token == null)
    throw new XMLParseException ("Unexpected EOF while parsing element content", tokenizer.getSource (), tokenizer.getOffset ());
  
  String content = tokenizer.getSource ().substring (beforeContent.getEndOffset (), token.getStartOffset ());
  startToken.setEndOffset (token.getEndOffset ());
  DocTypeElement element = new DocTypeElement (startToken, name, content);
  docType.add (element);
}
de.pdark.decentxmlXMLSourcesubstring

Javadoc

A piece of text between two offsets.

Note: start

Popular methods of XMLSource

  • charAt
    A character at a specific offset in the source
  • length
    The length (number of characters) in the source

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • setScale (BigDecimal)
  • onCreateOptionsMenu (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Notification (javax.management)
  • BoxLayout (javax.swing)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now