Moves the begin-index as long as a character contain in the array is at
the beginning.

@param annotation
the annotation to be trimmed
@param ws
an array of chars to be trimmed
@param <T>
the annotation type
@return the trimmed annotation
@since 0.4.2
499767
public static <T extends Annotation> T trimBegin(T annotation, char... ws) {
		char[] s = annotation.getCoveredText().toCharArray();
		if (s.length == 0)
			return annotation;

		int b = 0;
		while (ArrayUtils.contains(ws, s[b])) {
			b++;
		}

		annotation.setBegin(annotation.getBegin() + b);
		return annotation;
	}
1202497
public static void handle(String s, AnnotationHandler ah) {
        Map<String, Map<String, String>> l = new LinkedHashMap<String, Map<String, String>>();
        Matcher m = annPattern.matcher(s);
        while (m.find()) {
//            for (int i = 1; i <= m.groupCount(); i++) {
//                System.out.println("Group " + i + " '" + m.group(i) + "'");
//            }

            String rest = s.substring(m.end(0)).trim();
            String srcLine = null;
            if (rest.indexOf('\n') > -1) {
                srcLine = rest.substring(0, rest.indexOf('\n'));
            } else {
                srcLine = rest;
            }

            Map<String, String> val = new LinkedHashMap<String, String>();
            String annArgs = m.group(3);
            if (annArgs == null) {
                // no annotations arguments
                // e.g   '@Function'
            } else if (annArgs.indexOf('=') > -1) {
                // KVP annotation
                // e.g.  '@Function(name="test", scope="global")'
                StringTokenizer t = new StringTokenizer(annArgs, ",");
                while (t.hasMoreTokens()) {
                    String arg = t.nextToken();
                    String key = arg.substring(0, arg.indexOf('='));
                    String value = arg.substring(arg.indexOf('=') + 1);
                    val.put(key.trim(), value.trim());
                }
            } else {
                // single value annotation
                // e.g.  '@Function("test");
                val.put(AnnotationHandler.VALUE, annArgs);
            }

            l.put(m.group(1), val);

            // If the next line also has an annotation
            // no source line will be passed into the handler
            if (!annTestPattern.matcher(srcLine).find()) {
                ah.handle(l, srcLine);
                ah.log(" Ann -> " + l);
                ah.log(" Src -> " + srcLine);
                l = new LinkedHashMap<String, Map<String, String>>();
            }
        }
    }
1036756
private void parseAnnotatableText(String text, Element parent) {
	  AnnotationNode annotation = null;
	  Matcher matcher = AnnotationParser.WIDGET_ANNOTATION_REGEX.matcher(text);

	  int previousEnd = 0;
	  while (matcher.find()){
		  int start = matcher.start();

		  // build a new text node for what is between last index and current annotation
		  if (start > previousEnd)	{
			  String segment = text.substring(previousEnd, start);
			  // ignore empty white space
			  if (segment.trim().length() > 0){
				  addTextNodeToParent (segment, parent, annotation);
				  annotation = null;
			  }
		  }

		  // parse the annotation
		  String annotationText = matcher.group().trim();
		  if (null != annotationText) {
		      annotation = new AnnotationNode(annotationText);
		      lines(annotation, annotationText);
		  }
		  previousEnd = matcher.end();
	  }
	  
	  // handle leftover text if we parsed some segment
	  if (previousEnd > 0 && previousEnd < text.length()){
		  String segment = text.substring(previousEnd);
		  if (segment.trim().length() > 0){
			  addTextNodeToParent (segment, parent, annotation);
			  annotation = null;
		  }
	  }
	  
	  // store the remaining annotation for use by whatever is parsed next
	  if (annotation != null)
		  add(annotation);
	  
	  // handle no annotations being found
	  if (previousEnd == 0){
		  Node dataNode;
		  if (parent.tagName().equals(titleTag) || parent.tagName().equals(textareaTag))
	        dataNode = TextNode.createFromEncoded(text, baseUri);
	      else // data not encoded but raw (for " in script)
	        dataNode = new DataNode(text, baseUri);
	      lines(dataNode, text);
	      
	      if (pendingAnnotation != null)
	          pendingAnnotation.apply(dataNode);
	      
		  // put the text node on the parent
		  parent.appendChild(dataNode);
	  }
  }
864987
public static void updateEnd(final Annotation annotation, final int end)
    {
        annotation.removeFromIndexes();
        annotation.setEnd(end);
        annotation.addToIndexes();
    }
1186912
public JCExpression qualident(boolean allowAnnos) {
        JCExpression t = toP(F.at(token.pos).Ident(ident()));
        while (token.kind == DOT) {
            int pos = token.pos;
            nextToken();
            List<JCAnnotation> tyannos = null;
            if (allowAnnos) {
                tyannos = typeAnnotationsOpt();
            }
            t = toP(F.at(pos).Select(t, ident()));
            if (tyannos != null && tyannos.nonEmpty()) {
                t = toP(F.at(tyannos.head.pos).AnnotatedType(tyannos, t));
            }
        }
        return t;
    }
1000523
private String getAnnotations(String id, long component)
  {
    String result = "";
    String incoming = "", outgoing = "";
    int nri = 1, nro = 1;

    if(referentOfToken.get(id) != null)
    {
      for (long l : referentOfToken.get(id).keySet())
      {
        if (referentList.get((int) l) != null && referentList.get((int) l).component == component
          && referentList.get((int) l).annotations != null && referentList.get((int) l).annotations.size() > 0)
        {
          int num = referentOfToken.get(id).get(l);
          if (num == 0 || num == 2)
          {
            for (SerializableAnnotation an : referentList.get((int) l).annotations)
            {
              if (nri == 1)
              {
                incoming = ", &lt;b&gt;incoming Annotations&lt;/b&gt;: " + an.getName() + "=" + an.getValue();
                nri--;
              }
              else
              {
                incoming += ", " + an.getName() + "=" + an.getValue();
              }
            }
          }
          if (num == 1 || num == 2)
          {
            for (SerializableAnnotation an : referentList.get((int) (long) l).annotations)
            {
              if (nro == 1)
              {
                outgoing = ", &lt;b&gt;outgoing Annotations&lt;/b&gt;: " + an.getName() + "=" + an.getValue();
                nro--; // remove l+"- "+
              }
              else
              {
                outgoing += ", " + an.getName() + "=" + an.getValue();
              }
            }
          }
        }
      }
    }
    if (nro < 1)
    {
      result += outgoing;
    }
    if (nri < 1)
    {
      result += incoming;
    }
    return result;
  }
135122
public static TypeAnnotationPosition
        classExtends(final List<TypePathEntry> location,
                     final JCLambda onLambda,
                     final int pos) {
        return classExtends(location, onLambda, 65535, pos);
    }
833625
public String handleSimpleAnnotation(String annotation, String value, String validate) {

		if (value == null)
			return "";

		// if validate contains annotation, do nothing
		if (validate != null && validate.toLowerCase().matches(".*@" + annotation.toLowerCase() + ".*"))
			return "";

		String result = " @" + annotation;

		// if validate contains named annotation parameters
		if (value.toLowerCase().matches(".*value.*") || value.toLowerCase().matches(".*message.*")) {
			result += "(" + value + ") ";
			return result + " ";
		}

		// a simple annotation only has parameters value and message
		String[] params = value.split(",");
		if (params.length == 1)
			result += "(" + params[0] + ")";
		if (params.length == 2)
			result += "(value=" + params[0] + ", message=" + params[1] + ")";

		return result + " ";
	}
999742
private static void inspectRecursively(Class<?> c, List<Method> s, Class<? extends Annotation> annotationType) {

      for (Method m : c.getDeclaredMethods()) {
         // don't bother if this method has already been overridden by a subclass
         if (notFound(m, s) && m.isAnnotationPresent(annotationType)) {
            s.add(m);
         }
      }

      if (!c.equals(Object.class)) {
         if (!c.isInterface()) {
            inspectRecursively(c.getSuperclass(), s, annotationType);
         }
         for (Class<?> ifc : c.getInterfaces()) inspectRecursively(ifc, s, annotationType);
      }
   }
1178602
public boolean isDocumentedAnnotation(TypeElement annotation) {
        for (AnnotationMirror anno : annotation.getAnnotationMirrors()) {
            if (getFullyQualifiedName(anno.getAnnotationType().asElement()).equals(
                    Documented.class.getName())) {
                return true;
            }
        }
        return false;
    }
622509
public static JCas getJCas(final Annotation annotation)
    {
        JCas result = null;
        try {
            result = annotation.getCAS().getJCas();
        }
        catch (final CASException e) {
            throw new IllegalArgumentException(e);
        }

        return result;

    }
792579
public final void mWS() throws RecognitionException {
        try {
            int _type = WS;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // org/javaruntype/type/parser/Type.g:124:5: ( ( ' ' )+ )
            // org/javaruntype/type/parser/Type.g:124:7: ( ' ' )+
            {
            // org/javaruntype/type/parser/Type.g:124:7: ( ' ' )+
            int cnt2=0;
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==' ') ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // org/javaruntype/type/parser/Type.g:124:8: ' '
            	    {
            	    match(' '); 

            	    }
            	    break;

            	default :
            	    if ( cnt2 >= 1 ) break loop2;
                        EarlyExitException eee =
                            new EarlyExitException(2, input);
                        throw eee;
                }
                cnt2++;
            } while (true);

            skip();

            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
152937
private static boolean hasAnnotation(String pkgInfo, String annotation) {
    if (!annotation.contains(".")) {
      ErrorUtil.warning(annotation + " is not a fully qualified name");
    }
    if (pkgInfo.contains("@" + annotation)) {
      return true;
    }
    int idx = annotation.lastIndexOf(".");
    String annotationPackageName = annotation.substring(0, idx);
    String annotationSimpleName = annotation.substring(idx + 1);
    if (pkgInfo.contains("@" + annotationSimpleName)) {
      String importRegex =
          "import\\s*" + annotationPackageName + "(\\.\\*|\\." + annotationSimpleName + ")";
      Pattern p = Pattern.compile(importRegex);
      Matcher m = p.matcher(pkgInfo);
      if (m.find()) {
        return true;
      }
    }
    return false;
  }
377944
public static KAMStoreDaoImpl.AnnotationDefinitionType convert(
            AnnotationDefinitionType wsAdt) {

        switch (wsAdt) {
        case ENUMERATION:
            return KAMStoreDaoImpl.AnnotationDefinitionType.ENUMERATION;
        case REGULAR_EXPRESSION:
            return KAMStoreDaoImpl.AnnotationDefinitionType.REGULAR_EXPRESSION;
        case URL:
            return KAMStoreDaoImpl.AnnotationDefinitionType.URL;
        }
        return null;
    }
1296460
public void addTimexAnnotation(String timexType, int begin, int end, Sentence sentence, String timexValue, String timexQuant,
			String timexFreq, String timexMod, String emptyValue, String timexId, String foundByRule, JCas jcas) {
		
		Timex3 annotation = new Timex3(jcas);
		annotation.setBegin(begin);
		annotation.setEnd(end);

		annotation.setFilename(sentence.getFilename());
		annotation.setSentId(sentence.getSentenceId());
		
		annotation.setEmptyValue(emptyValue);

		FSIterator iterToken = jcas.getAnnotationIndex(Token.type).subiterator(sentence);
		String allTokIds = "";
		while (iterToken.hasNext()) {
			Token tok = (Token) iterToken.next();
			if (tok.getBegin() <= begin && tok.getEnd() > begin) {
				annotation.setFirstTokId(tok.getTokenId());
				allTokIds = "BEGIN<-->" + tok.getTokenId();
			}
			if ((tok.getBegin() > begin) && (tok.getEnd() <= end)) {
				allTokIds = allTokIds + "<-->" + tok.getTokenId();
			}
		}
		annotation.setAllTokIds(allTokIds);
		annotation.setTimexType(timexType);
		annotation.setTimexValue(timexValue);
		annotation.setTimexId(timexId);
		annotation.setFoundByRule(foundByRule);
		if ((timexType.equals("DATE")) || (timexType.equals("TIME"))) {
			if ((timexValue.startsWith("X")) || (timexValue.startsWith("UNDEF"))) {
				annotation.setFoundByRule(foundByRule+"-relative");
			} else {
				annotation.setFoundByRule(foundByRule+"-explicit");
			}
		}
		if (!(timexQuant == null)) {
			annotation.setTimexQuant(timexQuant);
		}
		if (!(timexFreq == null)) {
			annotation.setTimexFreq(timexFreq);
		}
		if (!(timexMod == null)) {
			annotation.setTimexMod(timexMod);
		}
		annotation.addToIndexes();
		this.timex_counter++;
		
		Logger.printDetail(annotation.getTimexId()+"EXTRACTION PHASE:   "+" found by:"+annotation.getFoundByRule()+" text:"+annotation.getCoveredText());
		Logger.printDetail(annotation.getTimexId()+"NORMALIZATION PHASE:"+" found by:"+annotation.getFoundByRule()+" text:"+annotation.getCoveredText()+" value:"+annotation.getTimexValue());
		
	}
869377
@SuppressWarnings("WeakerAccess")
    protected final void addAnnotation(String annotation, Map<CharSequence, Object> values) {
        if (annotation != null) {
            String repeatedName = getRepeatedName(annotation);
            Object v = values.get(AnnotationMetadata.VALUE_MEMBER);
            if (v instanceof io.micronaut.core.annotation.AnnotationValue[]) {
                io.micronaut.core.annotation.AnnotationValue[] avs = (io.micronaut.core.annotation.AnnotationValue[]) v;
                for (io.micronaut.core.annotation.AnnotationValue av : avs) {
                    addRepeatable(annotation, av);
                }
            } else if (v instanceof Iterable && repeatedName != null) {
                Iterable i = (Iterable) v;
                for (Object o : i) {
                    if (o instanceof io.micronaut.core.annotation.AnnotationValue) {
                        addRepeatable(annotation, ((io.micronaut.core.annotation.AnnotationValue) o));
                    }
                }
            } else {
                Map<String, Map<CharSequence, Object>> allAnnotations = getAllAnnotations();
                addAnnotation(annotation, values, null, allAnnotations, false);
            }
        }
    }
1299258
public static List<ExecutableElement> getSortedAnnotationMembers(TypeElement annotation) {
    List<ExecutableElement> members = Lists.newArrayList(getMethods(annotation));
    Collections.sort(members, (m1, m2) -> getName(m1).compareTo(getName(m2)));
    return members;
  }