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);
    }
  }