Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.google.sitebricks.compiler;
 
Utility class helps XmlTemplateCompiler work with the DOM.

Author(s):
Dhanji R. Prasanna (dhanji@gmail.com)
 
class Dom {
  static final String LINE_NUMBER_ATTRIBUTE = "__SitebricksSaxLineNumber";
  private Dom() {
  }
  static String stripAnnotation(String text) {
        .matcher(text);
    //strip off the ending bit (annotation)
    if (matcher.find())
      return text.substring(0, matcher.start());
    return text;
  }

  

Parameters:
annotation A string reprenting an unparsed annotation of the form:
                                     "@MyAnn(property = [expr], ...)"
Returns:
A partially parsed array following this structure:
                  [0] -> "MyAnn" 
[1] -> "prop = [expr], ..."
  static String[] extractKeyAndContent(String annotation) {
    final int index = annotation.indexOf('(');
    //there's no content
    if (index < 0)
      return new String[]{annotation.substring(1).toLowerCase(), ""};
    String content = annotation.substring(index + 1, annotation.lastIndexOf(')'));
    //normalize empty string to null
    if ("".equals(content))
      content = null;
    return new String[]{annotation.substring(1, index).toLowerCase(), content};
  }
New to GrepCode? Check out our FAQ X