<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.uima.analysis_engine.metadata.impl;

import java.util.List;

import org.apache.uima.UIMAFramework;
import org.apache.uima.UIMA_IllegalArgumentException;
import org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData;
import org.apache.uima.analysis_engine.metadata.FlowConstraints;
import org.apache.uima.resource.ResourceManager;
import org.apache.uima.resource.metadata.Capability;
import org.apache.uima.resource.metadata.FsIndexCollection;
import org.apache.uima.resource.metadata.FsIndexDescription;
import org.apache.uima.resource.metadata.OperationalProperties;
import org.apache.uima.resource.metadata.TypePriorities;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.resource.metadata.impl.FsIndexCollection_impl;
import org.apache.uima.resource.metadata.impl.PropertyXmlInfo;
import org.apache.uima.resource.metadata.impl.ResourceMetaData_impl;
import org.apache.uima.resource.metadata.impl.XmlizationInfo;
import org.apache.uima.util.InvalidXMLException;
import org.apache.uima.util.XMLParser;
import org.apache.uima.util.XMLParser.ParsingOptions;
import org.w3c.dom.Element;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

/**
 * Reference implementation of {@link AnalysisEngineMetaData}.
 * 
 * 
 */
public class AnalysisEngineMetaData_impl extends ResourceMetaData_impl implements
        AnalysisEngineMetaData {
  static final long serialVersionUID = -3030574527767871396L;

  private boolean mAsynchronousModeSupported;

  private FlowConstraints mFlowConstraints;

  private AnalysisEngineMetaData[] mDelegateAnalysisEngineMetaData;

  private Capability[] mCapabilities = new Capability[0];

  private TypeSystemDescription mTypeSystem;

  private TypePriorities mTypePriorities;

  private FsIndexCollection mFsIndexCollection;

  private OperationalProperties mOperationalProperties;

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#resolveImports()
   */
  public void resolveImports() throws InvalidXMLException {
    resolveImports(UIMAFramework.newDefaultResourceManager());
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#resolveImports(org.apache.uima.resource.ResourceManager)
   */
  public void resolveImports(ResourceManager aResourceManager) throws InvalidXMLException {
    if (getTypeSystem() != null) {
      getTypeSystem().resolveImports(aResourceManager);
    }
    if (getTypePriorities() != null) {
      getTypePriorities().resolveImports(aResourceManager);
    }
    if (getFsIndexCollection() != null) {
      getFsIndexCollection().resolveImports(aResourceManager);
    }
  }

  /**
   * @see org.apache.uima.resource.metadata.AnalysisEngineMetaData#getCapabilities()
   */
  public Capability[] getCapabilities() {
    return mCapabilities;
  }

  /**
   * @see org.apache.uima.resource.metadata.AnalysisEngineMetaData#setCapabilities(Capability[])
   */
  public void setCapabilities(Capability[] aCapabilities) {
    if (aCapabilities == null) {
      throw new UIMA_IllegalArgumentException(UIMA_IllegalArgumentException.ILLEGAL_ARGUMENT,
              new Object[] { "null", "aCapabilities", "setCapabilities" });
    }
    mCapabilities = aCapabilities;
  }

  /**
   * @see org.apache.uima.resource.metadata.AnalysisEngineMetaData#getTypeSystem()
   */
  public TypeSystemDescription getTypeSystem() {
    return mTypeSystem;
  }

  /**
   * @see org.apache.uima.resource.metadata.AnalysisEngineMetaData#setTypeSystem(TypeSystemDescription)
   */
  public void setTypeSystem(TypeSystemDescription aTypeSystem) {
    mTypeSystem = aTypeSystem;
  }

  /**
   * @see org.apache.uima.resource.metadata.AnalysisEngineMetaData#getTypePriorities()
   */
  public TypePriorities getTypePriorities() {
    return mTypePriorities;
  }

  /**
   * @see org.apache.uima.resource.metadata.AnalysisEngineMetaData#setTypePriorities(org.apache.uima.analysis_engine.metadata.TypePriorities)
   */
  public void setTypePriorities(TypePriorities aTypePriorities) {
    mTypePriorities = aTypePriorities;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#getFsIndexCollection()
   */
  public FsIndexCollection getFsIndexCollection() {
    return mFsIndexCollection;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#setFsIndexCollection(org.apache.uima.resource.metadata.FsIndexCollection)
   */
  public void setFsIndexCollection(FsIndexCollection aFsIndexCollection) {
    mFsIndexCollection = aFsIndexCollection;
  }

  /**
   * @see org.apache.uima.resource.metadata.AnalysisEngineMetaData#getFsIndexes()
   */
  public FsIndexDescription[] getFsIndexes() {
    return mFsIndexCollection == null ? null : mFsIndexCollection.getFsIndexes();
  }

  /**
   * @see org.apache.uima.resource.metadata.AnalysisEngineMetaData#setFsIndexes(FsIndexDescription[])
   */
  public void setFsIndexes(FsIndexDescription[] aFsIndexes) {
    if (mFsIndexCollection == null) {
      mFsIndexCollection = new FsIndexCollection_impl();
    }
    mFsIndexCollection.setFsIndexes(aFsIndexes);
  }

  public OperationalProperties getOperationalProperties() {
    return mOperationalProperties;
  }

  public void setOperationalProperties(OperationalProperties aOperationalProperties) {
    mOperationalProperties = aOperationalProperties;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.uima.resource.metadata.impl.MetaDataObject_impl#writePropertyAsElement(org.apache.uima.resource.metadata.impl.PropertyXmlInfo,
   *      java.lang.String, org.xml.sax.ContentHandler)
   */
  protected void writePropertyAsElement(PropertyXmlInfo aPropInfo, String aNamespace,
          ContentHandler aContentHandler) throws SAXException {
    // Prevent the fsIndexes property from being written to XML - it exists only so old-style XML
    // can be read.<commit_msg>[UIMA-3256] fixup Javadocs<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.uima.analysis_engine.metadata.impl;

import java.util.List;

import org.apache.uima.UIMAFramework;
import org.apache.uima.UIMA_IllegalArgumentException;
import org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData;
import org.apache.uima.analysis_engine.metadata.FlowConstraints;
import org.apache.uima.resource.ResourceManager;
import org.apache.uima.resource.metadata.Capability;
import org.apache.uima.resource.metadata.FsIndexCollection;
import org.apache.uima.resource.metadata.FsIndexDescription;
import org.apache.uima.resource.metadata.OperationalProperties;
import org.apache.uima.resource.metadata.TypePriorities;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.resource.metadata.impl.FsIndexCollection_impl;
import org.apache.uima.resource.metadata.impl.PropertyXmlInfo;
import org.apache.uima.resource.metadata.impl.ResourceMetaData_impl;
import org.apache.uima.resource.metadata.impl.XmlizationInfo;
import org.apache.uima.util.InvalidXMLException;
import org.apache.uima.util.XMLParser;
import org.apache.uima.util.XMLParser.ParsingOptions;
import org.w3c.dom.Element;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

/**
 * Reference implementation of {@link AnalysisEngineMetaData}.
 * 
 * 
 */
public class AnalysisEngineMetaData_impl extends ResourceMetaData_impl implements
        AnalysisEngineMetaData {
  static final long serialVersionUID = -3030574527767871396L;

  private boolean mAsynchronousModeSupported;

  private FlowConstraints mFlowConstraints;

  private AnalysisEngineMetaData[] mDelegateAnalysisEngineMetaData;

  private Capability[] mCapabilities = new Capability[0];

  private TypeSystemDescription mTypeSystem;

  private TypePriorities mTypePriorities;

  private FsIndexCollection mFsIndexCollection;

  private OperationalProperties mOperationalProperties;

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#resolveImports()
   */
  public void resolveImports() throws InvalidXMLException {
    resolveImports(UIMAFramework.newDefaultResourceManager());
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#resolveImports(org.apache.uima.resource.ResourceManager)
   */
  public void resolveImports(ResourceManager aResourceManager) throws InvalidXMLException {
    if (getTypeSystem() != null) {
      getTypeSystem().resolveImports(aResourceManager);
    }
    if (getTypePriorities() != null) {
      getTypePriorities().resolveImports(aResourceManager);
    }
    if (getFsIndexCollection() != null) {
      getFsIndexCollection().resolveImports(aResourceManager);
    }
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#getCapabilities()
   */
  public Capability[] getCapabilities() {
    return mCapabilities;
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#setCapabilities(Capability[])
   */
  public void setCapabilities(Capability[] aCapabilities) {
    if (aCapabilities == null) {
      throw new UIMA_IllegalArgumentException(UIMA_IllegalArgumentException.ILLEGAL_ARGUMENT,
              new Object[] { "null", "aCapabilities", "setCapabilities" });
    }
    mCapabilities = aCapabilities;
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#getTypeSystem()
   */
  public TypeSystemDescription getTypeSystem() {
    return mTypeSystem;
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#setTypeSystem(TypeSystemDescription)
   */
  public void setTypeSystem(TypeSystemDescription aTypeSystem) {
    mTypeSystem = aTypeSystem;
  }

  /**
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#getTypePriorities()
   */
  public TypePriorities getTypePriorities() {
    return mTypePriorities;
  }

  /**
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#setTypePriorities(TypePriorities)
   */
  public void setTypePriorities(TypePriorities aTypePriorities) {
    mTypePriorities = aTypePriorities;
  }

  /** 
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#getFsIndexCollection()
   */
  public FsIndexCollection getFsIndexCollection() {
    return mFsIndexCollection;
  }

  /**
   * @see org.apache.uima.resource.metadata.ProcessingResourceMetaData#setFsIndexCollection(FsIndexCollection)
   */
  public void setFsIndexCollection(FsIndexCollection aFsIndexCollection) {
    mFsIndexCollection = aFsIndexCollection;
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#getFsIndexes()
   */
  public FsIndexDescription[] getFsIndexes() {
    return mFsIndexCollection == null ? null : mFsIndexCollection.getFsIndexes();
  }

  /**
   * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#setFsIndexes(FsIndexDescription[])
   */
  public void setFsIndexes(FsIndexDescription[] aFsIndexes) {
    if (mFsIndexCollection == null) {
      mFsIndexCollection = new FsIndexCollection_impl();
    }
    mFsIndexCollection.setFsIndexes(aFsIndexes);
  }

  public OperationalProperties getOperationalProperties() {
    return mOperationalProperties;
  }

  public void setOperationalProperties(OperationalProperties aOperationalProperties) {
    mOperationalProperties = aOperationalProperties;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.uima.resource.metadata.impl.MetaDataObject_impl#writePropertyAsElement(org.apache.uima.resource.metadata.impl.PropertyXmlInfo,
   *      java.lang.String, org.xml.sax.ContentHandler)
   */
  protected void writePropertyAsElement(PropertyXmlInfo aPropInfo, String aNamespace,
          ContentHandler aContentHandler) throws SAXException {
    // Prevent the fsIndexes property from being written to XML - it exists only so old-style XML
    // can be read.
{'fraction_non_alphanumeric': 0.09326845093268452, 'fraction_numerical': 0.003981420039814201, 'mean_word_length': 4.687211740041929, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6083056', 'n_tokens_mistral': 4006, 'n_tokens_neox': 3865, 'n_words': 743}