/** * Returns the name of this attribute in original case. * <p> * This is exactly equivalent to {@link #getNameSegment()}<code>.toString()</code>. * * @return the name of this attribute in original case. * @see #getKey() */ public String getName() { return nameSegment.toString(); }
@Override public void element(final Element element, final Context context, final BugList bugs) { final String tagName = element.getName(); if (tagName.equals(CF.CFQUERY)) { String queryGuts = element.getContent().toString().replaceAll("\\s+", ""); queryGuts = queryGuts.toLowerCase(); if (queryGuts.contains(selectStar)) { context.addMessage("SQL_SELECT_STAR", null); } } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { final String tagName = element.getName(); if (tagName.equals(CF.CFQUERY)) { String queryGuts = element.getContent().toString().replaceAll("\\s+", ""); queryGuts = queryGuts.toLowerCase(); if (queryGuts.contains(selectStar)) { context.addMessage("SQL_SELECT_STAR", null); } } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { final String elementName = element.getName(); if (elementName.equals(CF.CFCOMPONENT)) { // this includes whitespace-change it final int total = element.getContent().toString().split("\\n").length; checkSize(LENGTH_THRESHOLD, "EXCESSIVE_COMPONENT_LENGTH", context, 1, 0, total, bugs); } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { final String elementName = element.getName(); if (elementName.equals(CF.CFCOMPONENT)) { // this includes whitespace-change it final int total = element.getContent().toString().split("\\n").length; checkSize(LENGTH_THRESHOLD, "EXCESSIVE_COMPONENT_LENGTH", context, 1, 0, total, bugs); } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { if (element.getName().equals(CF.CFSET)) { final String content = element.getStartTag().getTagContent().toString(); if (content.toLowerCase().contains("arraynew(1)")) { context.addMessage("AVOID_USING_ARRAYNEW", null); } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { if (element.getName().equals(CF.CFSET)) { final String content = element.getStartTag().getTagContent().toString(); if (content.toLowerCase().contains("arraynew(1)")) { context.addMessage("AVOID_USING_ARRAYNEW", null); } } }
/** * Returns the raw (not {@linkplain CharacterReference#decode(CharSequence) decoded}) value of the attribute, or null if the attribute {@linkplain Attribute#hasValue() has no value}. * <p> * This is an internal convenience method. * * @return the raw (not {@linkplain CharacterReference#decode(CharSequence) decoded}) value of the attribute, or null if the attribute {@linkplain Attribute#hasValue() has no value}. */ String getRawValue(final String name) { final Attribute attribute=get(name); return attribute==null || !attribute.hasValue() ? null : attribute.getValueSegment().toString(); }
private String getReturnValue(Element element) throws ZestAssignFailException { if (returnElement) { return element.getContent().toString(); } else if (returnAttribute) { return element.getAttributeValue(returnedAttributeName); } else { throw new ZestAssignFailException(this, "A selection method must be configured"); } }
public Pair<Integer, String> getBodyText() { Segment content = innerElement.getContent(); Integer lineNum = innerElement.getSource().getRow(content.getBegin()); String nl = content.getSource().getNewLine(); String body = nl==null? content.toString(): content.toString().replace(nl, "\n"); return Pair.make(lineNum, body); }
public Pair<Integer, String> getBodyText() { Segment content = innerElement.getContent(); Integer lineNum = innerElement.getSource().getRow(content.getBegin()); String nl = content.getSource().getNewLine(); String body = nl==null? content.toString(): content.toString().replace(nl, "\n"); return Pair.make(lineNum, body); }
private void parseUse(StartTag tag) { String content = tag.getTagContent().toString(); String[] parts = StringUtils.split(content, ":", 2); if (parts.length != 2) { error(tag.getTagContent(), "Illegal syntax for 'use' instruction"); return; } String prefix = parts[0].trim(); String packageName = normalizeQualifiedName(parts[1]); use(tag.getTagContent(), prefix, packageName); }
private void parseUse(StartTag tag) { String content = tag.getTagContent().toString(); String[] parts = StringUtils.split(content, ":", 2); if (parts.length != 2) { error(tag.getTagContent(), "Illegal syntax for 'use' instruction"); return; } String prefix = parts[0].trim(); String packageName = normalizeQualifiedName(parts[1]); use(tag.getTagContent(), prefix, packageName); }
private void parseImport(StartTag tag) { String importedName = normalizeQualifiedName(tag.getTagContent().toString()); if (importedName.endsWith(".*")) { classResolver.importPackage(importedName); } else { if (classResolver.findClass(importedName) == null) { error(tag.getTagContent(), "Class was not found: " + importedName); } else { classResolver.importClass(importedName); } } }
private void parseImport(StartTag tag) { String importedName = normalizeQualifiedName(tag.getTagContent().toString()); if (importedName.endsWith(".*")) { classResolver.importPackage(importedName); } else { if (classResolver.findClass(importedName) == null) { error(tag.getTagContent(), "Class was not found: " + importedName); } else { classResolver.importClass(importedName); } } }
private static Appendable appendDecode(final Appendable appendable, final CharSequence encodedText, final int searchBegin, final boolean insideAttributeValue, final boolean convertNonBreakingSpaces) throws IOException { if (encodedText instanceof Segment) return appendDecode(appendable,(Segment)encodedText,searchBegin,insideAttributeValue,convertNonBreakingSpaces); final Config.UnterminatedCharacterReferenceSettings unterminatedCharacterReferenceSettings=Config.CurrentCompatibilityMode.getUnterminatedCharacterReferenceSettings(insideAttributeValue); final StreamedSource streamedSource=new StreamedSource(encodedText).setHandleTags(false).setUnterminatedCharacterReferenceSettings(unterminatedCharacterReferenceSettings).setSearchBegin(searchBegin); for (Segment segment : streamedSource) { if (segment instanceof CharacterReference) { ((CharacterReference)segment).appendCharTo(appendable,convertNonBreakingSpaces); } else { appendable.append(segment.toString()); // benchmark tests reveal (surprisingly) that converting to a string before appending is faster than appending the specified section of the encodedText or segment directly. // appendable.append(encodedText,segment.begin,segment.end); // appendable.append(segment); } } return appendable; }
private Expr parseExpr(Segment segment) { boolean hasErrors = false; org.teavm.flavour.expr.Parser exprParser = new org.teavm.flavour.expr.Parser(classResolver); Expr expr = exprParser.parse(segment.toString()); int offset = segment.getBegin(); for (Diagnostic diagnostic : exprParser.getDiagnostics()) { diagnostic = new Diagnostic(offset + diagnostic.getStart(), offset + diagnostic.getEnd(), diagnostic.getMessage()); diagnostics.add(diagnostic); hasErrors = true; } if (hasErrors) { return null; } return expr; }
private ObjectExpr parseObject(Segment segment) { boolean hasErrors = false; org.teavm.flavour.expr.Parser exprParser = new org.teavm.flavour.expr.Parser(classResolver); ObjectExpr expr = exprParser.parseObject(segment.toString()); int offset = segment.getBegin(); for (Diagnostic diagnostic : exprParser.getDiagnostics()) { diagnostic = new Diagnostic(offset + diagnostic.getStart(), offset + diagnostic.getEnd(), diagnostic.getMessage()); diagnostics.add(diagnostic); hasErrors = true; } if (hasErrors) { return null; } return expr; }
private ObjectExpr parseObject(Segment segment) { boolean hasErrors = false; org.teavm.flavour.expr.Parser exprParser = new org.teavm.flavour.expr.Parser(classResolver); ObjectExpr expr = exprParser.parseObject(segment.toString()); int offset = segment.getBegin(); for (Diagnostic diagnostic : exprParser.getDiagnostics()) { diagnostic = new Diagnostic(offset + diagnostic.getStart(), offset + diagnostic.getEnd(), diagnostic.getMessage()); diagnostics.add(diagnostic); hasErrors = true; } if (hasErrors) { return null; } return expr; }
private Expr parseExpr(Segment segment) { boolean hasErrors = false; org.teavm.flavour.expr.Parser exprParser = new org.teavm.flavour.expr.Parser(classResolver); Expr expr = exprParser.parse(segment.toString()); int offset = segment.getBegin(); for (Diagnostic diagnostic : exprParser.getDiagnostics()) { diagnostic = new Diagnostic(offset + diagnostic.getStart(), offset + diagnostic.getEnd(), diagnostic.getMessage()); diagnostics.add(diagnostic); hasErrors = true; } if (hasErrors) { return null; } return expr; }