private void setValue(LexicalAttribute attribute, String value) {
    if (value == null || value.length() == 0) return;
    byte code = lexiconFile.getOrCreateAttributeCode(attribute, value);

    int attributeBit = attributeBitMap.get(attribute);

    // count bits to the left of current marker
    int bitCount = 0;
    for (int i = 0x1; i < attributeBit; i *= 2) {
      if ((attributeMarker & i) > 0) bitCount++;
    }

    if ((attributeMarker & attributeBit) > 0) {
      // replace existing value
      attributeCodes[bitCount] = code;
    } else {
      // insert new value, means upping all higher values
      byte[] newAttributeCodes = new byte[attributeCodes.length + 1];
      for (int i = 0; i < newAttributeCodes.length; i++) {
        if (i < bitCount) newAttributeCodes[i] = attributeCodes[i];
        else if (i == bitCount) newAttributeCodes[i] = code;
        else newAttributeCodes[i] = attributeCodes[i - 1];
      }
      attributeCodes = newAttributeCodes;
      attributeMarker = (attributeMarker | attributeBit);
    }
  }
 private String getValue(LexicalAttribute attribute) {
   int attributeBit = attributeBitMap.get(attribute);
   if ((attributeMarker & attributeBit) == 0) {
     return "";
   }
   // count bits to the left of current marker
   int bitCount = 0;
   for (int i = 0x1; i < attributeBit; i *= 2) {
     if ((attributeMarker & i) > 0) bitCount++;
   }
   byte code = attributeCodes[bitCount];
   String value = lexiconFile.getAttributeValue(attribute, code);
   return value;
 }
  @Override
  public void setAttribute(String attribute, String value) {
    if (attribute.equals(LexicalAttribute.Word.name())) this.setWord(value);
    else if (attribute.equals(LexicalAttribute.Lemma.name())) this.setLemma(value);

    LexicalAttribute myAttribute = null;
    try {
      myAttribute = LexicalAttribute.valueOf(attribute);
    } catch (IllegalArgumentException e) {
      // do nothing
    }
    if (myAttribute == null) {
      myAttribute = lexiconFile.getAttributeForName(attribute);
    }
    this.setValue(myAttribute, value);
  }
  @Override
  public String getAttribute(String attribute) {
    if (attribute.equals(LexicalAttribute.Word.name())) return this.word;
    else if (attribute.equals(LexicalAttribute.Lemma.name())) return this.lemma;

    LexicalAttribute myAttribute = null;
    try {
      myAttribute = LexicalAttribute.valueOf(attribute);
    } catch (IllegalArgumentException e) {
      // do nothing
    }
    if (myAttribute == null) {
      myAttribute = lexiconFile.getAttributeForName(attribute);
    }
    return this.getValue(myAttribute);
  }