Examples of CharacterSet


Examples of net.sf.lapg.lex.CharacterSet

    CharacterSet.Builder b = new CharacterSet.Builder();

    b.clear();
    b.addRange('a', 'z');
    b.addSymbol('_');
    CharacterSet set = b.create();

    b.clear();
    b.addSymbol('i');
    b.addSymbol('e');
    b.addSymbol('c');
    CharacterSet set2 = b.create();
    Assert.assertEquals("[95,97-98,100,102-104,106-122]", b.subtract(set, set2).toString());
  }
View Full Code Here

Examples of net.sf.lapg.lex.CharacterSet

    CharacterSet.Builder b = new CharacterSet.Builder();

    b.clear();
    b.addRange('a', 'l');
    b.addSymbol('_');
    CharacterSet set = b.create();

    b.clear();
    b.addSymbol('i');
    b.addSymbol('e');
    b.addSymbol('c');
    CharacterSet set2 = b.create();

    set = b.subtract(set, set2);
    Iterator<int[]> it = set.iterator();

    Assert.assertEquals(true, it.hasNext());
View Full Code Here

Examples of net.sf.lapg.lex.CharacterSet

  private static final int TESTLEN = 9;

  public void testSubtractGeneric() {
    CharacterSet.Builder b = new CharacterSet.Builder();
    CharacterSet s1, s2, s3;
    int[] array1 = new int[TESTLEN];
    int[] array2 = new int[TESTLEN];
    int[] array3 = new int[TESTLEN];

    fillArray(array1, 255);
View Full Code Here

Examples of net.sf.lapg.lex.CharacterSet

    }
  }

  public void testIntersectGeneric() {
    CharacterSet.Builder b = new CharacterSet.Builder();
    CharacterSet s1, s2, s3;
    int[] array1 = new int[TESTLEN];
    int[] array2 = new int[TESTLEN];
    int[] array3 = new int[TESTLEN];

    for(int i = 0; i < (1<<TESTLEN); i++) {
View Full Code Here

Examples of net.sf.lapg.lex.CharacterSet

  private static final int ARTESTLEN = 12;

  public void testAddRangeGeneric() {
    CharacterSet.Builder b = new CharacterSet.Builder();
    CharacterSet s2, s3;
    int[] array1 = new int[ARTESTLEN];
    int[] array2 = new int[ARTESTLEN];

    for(int i = 0; i < (1<<ARTESTLEN); i++) {
      fillArray(array1, i);

      for(int start = 0; start < ARTESTLEN; start++) {
        for(int end = start; end < ARTESTLEN; end++) {
          for(int e = 0; e < ARTESTLEN; e++) {
            array2[e] = (e >= start && e <= end) ? 1 : array1[e];
          }
          b.clear();

          int q = 0;
          while(q < array1.length) {
            if(array1[q] == 1) {
              int st = q;
              while(q+1 < array1.length && array1[q+1] == 1) {
                q++;
              }
              b.addRange(st, q);
            }
            q++;
          }

          b.addRange(start, end);
          s2 = b.create();

          s3 = fromArray(array2,b);
          Assert.assertEquals(i+": "+start+"-"+end,
              s3.toString(), s2.toString());
        }
      }
    }
  }
View Full Code Here

Examples of net.sf.lapg.lex.CharacterSet

    }
  }

  private static void subtract(int[] a1, int[] a2, String result) {
    CharacterSet.Builder b = new CharacterSet.Builder();
    Assert.assertEquals(result, b.subtract(new CharacterSet(a1, a1.length), new CharacterSet(a2, a2.length)).toString());
  }
View Full Code Here

Examples of net.sourceforge.chaperon.grammar.token.definition.CharacterSet

        characterclass.setMaxOccurs(getMaxOccursFromAttributes(atts));
        stack.push(characterclass);
      }
      else if (localName.equals(CHARACTERSET_ELEMENT))
      {
        CharacterSet characterset = new CharacterSet();

        characterset.setCharacters(atts.getValue(CHARACTERSET_CHARACTERS_ATTRIBUTE));
        stack.push(characterset);
      }
      else if (localName.equals(CHARACTERINTERVAL_ELEMENT))
      {
        CharacterInterval characterinterval = new CharacterInterval();
View Full Code Here

Examples of net.sourceforge.chaperon.model.pattern.CharacterSet

      {
        if (characterclass.getCharacterClassElement(i) instanceof CharacterInterval)
          statecount++;
        else if (characterclass.getCharacterClassElement(i) instanceof CharacterSet)
        {
          CharacterSet set = (CharacterSet)characterclass.getCharacterClassElement(i);

          statecount += set.getCharacters().length();
        }
      }

      statecount++;
    }
View Full Code Here

Examples of net.sourceforge.chaperon.model.pattern.CharacterSet

          state = stateindex--;
          automaton.addTransition(firststate, state);
        }
        else if (element.getCharacterClassElement(i) instanceof CharacterSet)
        {
          CharacterSet set = (CharacterSet)element.getCharacterClassElement(i);
          String chars = set.getCharacters();

          for (int j = 0; j<chars.length(); j++)
          {
            automaton.setType(stateindex, PatternAutomaton.TYPE_MATCH);
            automaton.setInterval(stateindex, chars.charAt(j), chars.charAt(j));
            automaton.addTransition(stateindex, laststate);
            state = stateindex--;
            automaton.addTransition(firststate, state);
          }
        }
      }

      return firststate;
    }
    else
    {
      state = stateindex--;
      automaton.setType(state, PatternAutomaton.TYPE_MATCHANY);
      automaton.setTransitions(state, new int[]{laststate});
      for (int i = element.getCharacterClassElementCount()-1; i>=0; i--)
      {
        if (element.getCharacterClassElement(i) instanceof CharacterInterval)
        {
          CharacterInterval interval = (CharacterInterval)element.getCharacterClassElement(i);

          automaton.setType(stateindex, PatternAutomaton.TYPE_MATCH);
          automaton.setInterval(stateindex, interval.getMinimum(), interval.getMaximum());
          automaton.setTransitions(stateindex, new int[]{state});
          state = stateindex--;
        }
        else if (element.getCharacterClassElement(i) instanceof CharacterSet)
        {
          CharacterSet set = (CharacterSet)element.getCharacterClassElement(i);
          String chars = set.getCharacters();

          for (int j = 0; j<chars.length(); j++)
          {
            automaton.setType(stateindex, PatternAutomaton.TYPE_EXMATCH);
            automaton.setInterval(stateindex, chars.charAt(j), chars.charAt(j));
View Full Code Here

Examples of org.apache.fop.afp.fonts.CharacterSet

            if (characterset == null) {
                log.error("Mandatory afp-font configuration attribute 'characterset=' is missing");
                return null;
            }
            String name = afpFontCfg.getAttribute("name", characterset);
            CharacterSet characterSet = null;
            String base14 = afpFontCfg.getAttribute("base14-font", null);
            if (base14 != null) {
                try {
                    Class clazz = Class.forName("org.apache.fop.fonts.base14."
                            + base14);
                    try {
                        Typeface tf = (Typeface)clazz.newInstance();
                        characterSet = CharacterSetBuilder.getInstance()
                                        .build(characterset, codepage, encoding, tf);
                    } catch (Exception ie) {
                        String msg = "The base 14 font class " + clazz.getName()
                                + " could not be instantiated";
                        log.error(msg);
                    }
                } catch (ClassNotFoundException cnfe) {
                    String msg = "The base 14 font class for " + characterset
                            + " could not be found";
                    log.error(msg);
                }
            } else {
                try {
                    characterSet = CharacterSetBuilder.getInstance().build(
                            characterset, codepage, encoding, accessor);
                } catch (IOException ioe) {
                    toConfigurationException(codepage, characterset, ioe);
                }
            }
            // Return new font object
            return new OutlineFont(name, characterSet);

        } else if ("CIDKeyed".equalsIgnoreCase(type)) {
            String characterset = afpFontCfg.getAttribute("characterset");
            if (characterset == null) {
                log.error("Mandatory afp-font configuration attribute 'characterset=' is missing");
                return null;
            }
            String name = afpFontCfg.getAttribute("name", characterset);
            CharacterSet characterSet = null;
            try {
                characterSet = CharacterSetBuilder.getDoubleByteInstance()
                                .build(characterset, codepage, encoding, accessor);
            } catch (IOException ioe) {
                toConfigurationException(codepage, characterset, ioe);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.