private void parseIndexing(
      final XMLExtendedStreamReader reader,
      final ModelNode parentAddress,
      final ModelNode repository)
      throws XMLStreamException {
    if (reader.getAttributeCount() > 0) {
      for (int i = 0; i < reader.getAttributeCount(); i++) {
        String attrName = reader.getAttributeLocalName(i);
        String attrValue = reader.getAttributeValue(i);
        Attribute element = Attribute.forName(attrName);
        switch (element) {
          case REBUILD_UPON_STARTUP:
            ModelAttributes.REBUILD_INDEXES_UPON_STARTUP.parseAndSetParameter(
                attrValue, repository, reader);
            break;
          case THREAD_POOL:
            ModelAttributes.THREAD_POOL.parseAndSetParameter(attrValue, repository, reader);
            break;
          case BATCH_SIZE:
            ModelAttributes.BATCH_SIZE.parseAndSetParameter(attrValue, repository, reader);
            break;
          case READER_STRATEGY:
            ModelAttributes.READER_STRATEGY.parseAndSetParameter(attrValue, repository, reader);
            break;
          case MODE:
            ModelAttributes.MODE.parseAndSetParameter(attrValue, repository, reader);
            break;
          case SYSTEM_CONTENT_MODE:
            ModelAttributes.SYSTEM_CONTENT_MODE.parseAndSetParameter(attrValue, repository, reader);
            break;
          case ASYNC_THREAD_POOL_SIZE:
            ModelAttributes.ASYNC_THREAD_POOL_SIZE.parseAndSetParameter(
                attrValue, repository, reader);
            break;
          case ASYNC_MAX_QUEUE_SIZE:
            ModelAttributes.ASYNC_MAX_QUEUE_SIZE.parseAndSetParameter(
                attrValue, repository, reader);
            break;
          case ANALYZER_CLASSNAME:
            ModelAttributes.ANALYZER_CLASSNAME.parseAndSetParameter(attrValue, repository, reader);
            break;
          case ANALYZER_MODULE:
            ModelAttributes.ANALYZER_MODULE.parseAndSetParameter(attrValue, repository, reader);
            break;
          default:
            if (attrName.startsWith("hibernate")) {
              repository.get(attrName).set(attrValue);
            } else {
              throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
      }
    }

    requireNoElements(reader);
  }
  private ModelNode parseRamIndexStorage(
      final XMLExtendedStreamReader reader, final String repositoryName) throws XMLStreamException {
    final ModelNode storageType = new ModelNode();
    storageType.get(OP).set(ADD);
    storageType
        .get(OP_ADDR)
        .add(SUBSYSTEM, ModeShapeExtension.SUBSYSTEM_NAME)
        .add(ModelKeys.REPOSITORY, repositoryName)
        .add(ModelKeys.CONFIGURATION, ModelKeys.INDEX_STORAGE)
        .add(ModelKeys.STORAGE_TYPE, ModelKeys.RAM_INDEX_STORAGE);

    if (reader.getAttributeCount() > 0) {
      for (int i = 0; i < reader.getAttributeCount(); i++) {
        String attrName = reader.getAttributeLocalName(i);
        String attrValue = reader.getAttributeValue(i);
        Attribute element = Attribute.forName(attrName);
        switch (element) {
          case THREAD_POOL:
            ModelAttributes.THREAD_POOL.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case BATCH_SIZE:
            ModelAttributes.BATCH_SIZE.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case READER_STRATEGY:
            ModelAttributes.READER_STRATEGY.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case MODE:
            ModelAttributes.MODE.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case ASYNC_THREAD_POOL_SIZE:
            ModelAttributes.ASYNC_THREAD_POOL_SIZE.parseAndSetParameter(
                attrValue, storageType, reader);
            break;
          case ASYNC_MAX_QUEUE_SIZE:
            ModelAttributes.ASYNC_MAX_QUEUE_SIZE.parseAndSetParameter(
                attrValue, storageType, reader);
            break;
          case ANALYZER_CLASSNAME:
            ModelAttributes.ANALYZER_CLASSNAME.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case ANALYZER_MODULE:
            ModelAttributes.ANALYZER_MODULE.parseAndSetParameter(attrValue, storageType, reader);
            break;
          default:
            storageType.get(attrName).set(attrValue);
            break;
        }
      }
    }

    requireNoElements(reader);

    return storageType;
  }
  private ModelNode parseFileIndexStorage(
      final XMLExtendedStreamReader reader, final String repositoryName, String name)
      throws XMLStreamException {
    final ModelNode storageType = new ModelNode();
    storageType.get(OP).set(ADD);
    storageType
        .get(OP_ADDR)
        .add(SUBSYSTEM, ModeShapeExtension.SUBSYSTEM_NAME)
        .add(ModelKeys.REPOSITORY, repositoryName)
        .add(ModelKeys.CONFIGURATION, ModelKeys.INDEX_STORAGE)
        .add(ModelKeys.STORAGE_TYPE, name);

    if (reader.getAttributeCount() > 0) {
      for (int i = 0; i < reader.getAttributeCount(); i++) {
        String attrName = reader.getAttributeLocalName(i);
        String attrValue = reader.getAttributeValue(i);
        Attribute attribute = Attribute.forName(attrName);
        switch (attribute) {
            // Set these as properties on the storage ModelNode ...
          case FORMAT:
            ModelAttributes.INDEX_FORMAT.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case REBUILD_UPON_STARTUP:
            ModelAttributes.REBUILD_INDEXES_UPON_STARTUP.parseAndSetParameter(
                attrValue, storageType, reader);
            break;
          case THREAD_POOL:
            ModelAttributes.THREAD_POOL.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case BATCH_SIZE:
            ModelAttributes.BATCH_SIZE.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case READER_STRATEGY:
            ModelAttributes.READER_STRATEGY.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case MODE:
            ModelAttributes.MODE.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case ASYNC_THREAD_POOL_SIZE:
            ModelAttributes.ASYNC_THREAD_POOL_SIZE.parseAndSetParameter(
                attrValue, storageType, reader);
            break;
          case ASYNC_MAX_QUEUE_SIZE:
            ModelAttributes.ASYNC_MAX_QUEUE_SIZE.parseAndSetParameter(
                attrValue, storageType, reader);
            break;
          case ANALYZER_CLASSNAME:
            ModelAttributes.ANALYZER_CLASSNAME.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case ANALYZER_MODULE:
            ModelAttributes.ANALYZER_MODULE.parseAndSetParameter(attrValue, storageType, reader);
            break;
            // These are file-related
          case RELATIVE_TO:
            ModelAttributes.RELATIVE_TO.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case PATH:
            ModelAttributes.PATH.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case ACCESS_TYPE:
            ModelAttributes.ACCESS_TYPE.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case LOCKING_STRATEGY:
            ModelAttributes.LOCKING_STRATEGY.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case REFRESH_PERIOD:
            ModelAttributes.REFRESH_PERIOD.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case COPY_BUFFER_SIZE:
            ModelAttributes.COPY_BUFFER_SIZE.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case SOURCE_PATH:
            ModelAttributes.SOURCE_PATH.parseAndSetParameter(attrValue, storageType, reader);
            break;
          case SOURCE_RELATIVE_TO:
            ModelAttributes.SOURCE_RELATIVE_TO.parseAndSetParameter(attrValue, storageType, reader);
            break;
            // These are JMS-related
          case CONNECTION_FACTORY_JNDI_NAME:
            ModelAttributes.CONNECTION_FACTORY_JNDI_NAME.parseAndSetParameter(
                attrValue, storageType, reader);
            break;
          case QUEUE_JNDI_NAME:
            ModelAttributes.QUEUE_JNDI_NAME.parseAndSetParameter(attrValue, storageType, reader);
            break;
          default:
            storageType.get(attrName).set(attrValue);
            break;
        }
      }
    }
    requireNoElements(reader);

    return storageType;
  }