Exemplo n.º 1
0
 public boolean verify(
     Model model,
     Object content,
     QName name,
     Object valueObject,
     Locator locator,
     VerifierContext context) {
   Reporter reporter = context.getReporter();
   boolean failed = false;
   assert valueObject instanceof String;
   String value = (String) valueObject;
   String[] components = value.split("[ \t\r\n]+");
   if (!Positions.isPosition(components, locator, context, null)) {
     reporter.logInfo(
         reporter.message(locator, "*KEY*", "Bad <position> expression ''{0}''.", value));
     failed = true;
   }
   return !failed;
 }
Exemplo n.º 2
0
 private void warnOnCounterViolations(LayoutState ls) {
   Reporter reporter = context.getReporter();
   ls.finalizeCounters();
   int regions = ls.getCounter(LayoutState.Counter.REGIONS_IN_CANVAS);
   if ((maxRegions >= 0) && (regions > maxRegions))
     reporter.logWarning(
         reporter.message(
             "*KEY*",
             "Regions per canvas limit exceeded, {0} present, must not exceed {1}.",
             regions,
             maxRegions));
   int lines = ls.getCounter(LayoutState.Counter.LINES_IN_CANVAS);
   if ((maxLines >= 0) && (lines > maxLines))
     reporter.logWarning(
         reporter.message(
             "*KEY*",
             "Lines per canvas limit exceeded, {0} present, must not exceed {1}.",
             lines,
             maxLines));
   int linesPerRegion = ls.getCounter(LayoutState.Counter.MAX_LINES_IN_REGION);
   if ((maxLinesPerRegion >= 0) && (linesPerRegion > maxLinesPerRegion))
     reporter.logWarning(
         reporter.message(
             "*KEY*",
             "Lines per region limit exceeded, {0} present, must not exceed {1}.",
             linesPerRegion,
             maxLinesPerRegion));
   int chars = ls.getCounter(LayoutState.Counter.CHARS_IN_CANVAS);
   if ((maxChars >= 0) && (chars > maxChars))
     reporter.logWarning(
         reporter.message(
             "*KEY*",
             "Characters per canvas limit exceeded, {0} present, must not exceed {1}.",
             chars,
             maxChars));
   int charsPerRegion = ls.getCounter(LayoutState.Counter.MAX_CHARS_IN_REGION);
   if ((maxCharsPerRegion >= 0) && (charsPerRegion > maxCharsPerRegion))
     reporter.logWarning(
         reporter.message(
             "*KEY*",
             "Characters per region limit exceeded, {0} present, must not exceed {1}.",
             charsPerRegion,
             maxCharsPerRegion));
   int charsPerLine = ls.getCounter(LayoutState.Counter.MAX_CHARS_IN_LINE);
   if ((maxCharsPerLine >= 0) && (charsPerLine > maxCharsPerLine))
     reporter.logWarning(
         reporter.message(
             "*KEY*",
             "Characters per line limit exceeded, {0} present, must not exceed {1}.",
             charsPerLine,
             maxCharsPerLine));
 }
Exemplo n.º 3
0
 @Override
 public int parseLongOption(List<String> args, int index) {
   Reporter reporter = context.getReporter();
   String arg = args.get(index);
   int numArgs = args.size();
   String option = arg;
   assert option.length() > 2;
   option = option.substring(2);
   if (option.equals("default-background-color")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     defaultBackgroundColor = args.get(++index);
   } else if (option.equals("default-color")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     defaultColor = args.get(++index);
   } else if (option.equals("default-font-families")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     defaultFontFamilies = args.get(++index);
   } else if (option.equals("default-whitespace")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     defaultWhitespace = args.get(++index);
   } else if (option.equals("font")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     if (fontSpecificationFileNames == null)
       fontSpecificationFileNames = new java.util.ArrayList<String>();
     fontSpecificationFileNames.add(args.get(++index));
   } else if (option.equals("font-directory")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     fontSpecificationDirectoryPath = args.get(++index);
   } else if (option.equals("line-breaker")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     lineBreakerName = args.get(++index);
   } else if (option.equals("max-regions")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     String count = args.get(++index);
     try {
       maxRegions = Integer.parseInt(count);
     } catch (NumberFormatException e) {
       throw new InvalidOptionUsageException(
           option, reporter.message("*KEY*", "bad count syntax: {0}", count));
     }
   } else if (option.equals("max-lines")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     String count = args.get(++index);
     try {
       maxLines = Integer.parseInt(count);
     } catch (NumberFormatException e) {
       throw new InvalidOptionUsageException(
           option, reporter.message("*KEY*", "bad count syntax: {0}", count));
     }
   } else if (option.equals("max-lines-per-region")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     String count = args.get(++index);
     try {
       maxLinesPerRegion = Integer.parseInt(count);
     } catch (NumberFormatException e) {
       throw new InvalidOptionUsageException(
           option, reporter.message("*KEY*", "bad count syntax: {0}", count));
     }
   } else if (option.equals("max-chars")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     String count = args.get(++index);
     try {
       maxChars = Integer.parseInt(count);
     } catch (NumberFormatException e) {
       throw new InvalidOptionUsageException(
           option, reporter.message("*KEY*", "bad count syntax: {0}", count));
     }
   } else if (option.equals("max-chars-per-region")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     String count = args.get(++index);
     try {
       maxCharsPerRegion = Integer.parseInt(count);
     } catch (NumberFormatException e) {
       throw new InvalidOptionUsageException(
           option, reporter.message("*KEY*", "bad count syntax: {0}", count));
     }
   } else if (option.equals("max-chars-per-line")) {
     if (index + 1 > numArgs) throw new MissingOptionArgumentException("--" + option);
     String count = args.get(++index);
     try {
       maxCharsPerLine = Integer.parseInt(count);
     } catch (NumberFormatException e) {
       throw new InvalidOptionUsageException(
           option, reporter.message("*KEY*", "bad count syntax: {0}", count));
     }
   } else index = index - 1;
   return index + 1;
 }