Program: 11903
Project: 11903
Buggy source:
protected void init(XMLResource resource,Map options){
  useCache=Boolean.TRUE.equals(options.get(XMLResource.OPTION_CONFIGURATION_CACHE));
  nameInfo=new NameInfoImpl();
  declareXSI=false;
  keepDefaults=Boolean.TRUE.equals(options.get(XMLResource.OPTION_KEEP_DEFAULT_CONTENT));
  useEncodedAttributeStyle=Boolean.TRUE.equals(options.get(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE));
  declareSchemaLocationImplementation=Boolean.TRUE.equals(options.get(XMLResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION));
  declareSchemaLocation=declareSchemaLocationImplementation || Boolean.TRUE.equals(options.get(XMLResource.OPTION_SCHEMA_LOCATION));
  Object saveTypeInfoOption=options.get(XMLResource.OPTION_SAVE_TYPE_INFORMATION);
  if (saveTypeInfoOption instanceof Boolean) {
    saveTypeInfo=saveTypeInfoOption.equals(Boolean.TRUE);
    if (saveTypeInfo) {
      xmlTypeInfo=new XMLTypeInfo(){
        public boolean shouldSaveType(        EClass objectType,        EClass featureType,        EStructuralFeature feature){
          return objectType != anyType;
        }
        public boolean shouldSaveType(        EClass objectType,        EClassifier featureType,        EStructuralFeature feature){
          return true;
        }
      }
;
    }
  }
 else {
    saveTypeInfo=saveTypeInfoOption != null;
    if (saveTypeInfo) {
      xmlTypeInfo=(XMLTypeInfo)saveTypeInfoOption;
    }
  }
  anyType=(EClass)options.get(XMLResource.OPTION_ANY_TYPE);
  anySimpleType=(EClass)options.get(XMLResource.OPTION_ANY_SIMPLE_TYPE);
  if (anyType == null) {
    anyType=XMLTypePackage.eINSTANCE.getAnyType();
    anySimpleType=XMLTypePackage.eINSTANCE.getSimpleAnyType();
  }
  Object extendedMetaDataOption=options.get(XMLResource.OPTION_EXTENDED_META_DATA);
  if (extendedMetaDataOption instanceof Boolean) {
    if (extendedMetaDataOption.equals(Boolean.TRUE)) {
      extendedMetaData=resource == null || resource.getResourceSet() == null ? ExtendedMetaData.INSTANCE : new BasicExtendedMetaData(resource.getResourceSet().getPackageRegistry());
    }
  }
 else {
    extendedMetaData=(ExtendedMetaData)options.get(XMLResource.OPTION_EXTENDED_META_DATA);
  }
  if (!toDOM) {
    declareXML=!Boolean.FALSE.equals(options.get(XMLResource.OPTION_DECLARE_XML));
    if (options.get(XMLResource.OPTION_FLUSH_THRESHOLD) instanceof Integer) {
      flushThreshold=((Integer)options.get(XMLResource.OPTION_FLUSH_THRESHOLD)).intValue();
    }
    String temporaryFileName=null;
    if (Boolean.TRUE.equals(options.get(XMLResource.OPTION_USE_FILE_BUFFER))) {
      try {
        temporaryFileName=File.createTempFile("String_Node_Str",null).getPath();
      }
 catch (      IOException exception) {
      }
    }
    Integer lineWidth=(Integer)options.get(XMLResource.OPTION_LINE_WIDTH);
    int effectiveLineWidth=lineWidth == null ? Integer.MAX_VALUE : lineWidth.intValue();
    String publicId=null, systemId=null;
    if (resource != null && Boolean.TRUE.equals(options.get(XMLResource.OPTION_SAVE_DOCTYPE))) {
      publicId=resource.getPublicId();
      systemId=resource.getSystemId();
    }
    if (useCache) {
      doc=ConfigurationCache.INSTANCE.getPrinter();
      doc.reset(publicId,systemId,effectiveLineWidth,temporaryFileName);
      escape=Boolean.TRUE.equals(options.get(XMLResource.OPTION_SKIP_ESCAPE)) ? null : ConfigurationCache.INSTANCE.getEscape();
    }
 else {
      doc=new XMLString(effectiveLineWidth,publicId,systemId,temporaryFileName);
      escape=Boolean.TRUE.equals(options.get(XMLResource.OPTION_SKIP_ESCAPE)) ? null : new Escape();
    }
    if (Boolean.FALSE.equals(options.get(XMLResource.OPTION_FORMATTED))) {
      doc.setUnformatted(true);
    }
    escapeURI=Boolean.FALSE.equals(options.get(XMLResource.OPTION_SKIP_ESCAPE_URI)) ? escape : null;
    if (options.containsKey(XMLResource.OPTION_ENCODING)) {
      encoding=(String)options.get(XMLResource.OPTION_ENCODING);
    }
 else     if (resource != null) {
      encoding=resource.getEncoding();
    }
    if (options.containsKey(XMLResource.OPTION_XML_VERSION)) {
      xmlVersion=(String)options.get(XMLResource.OPTION_XML_VERSION);
    }
 else     if (resource != null) {
      xmlVersion=resource.getXMLVersion();
    }
    if (escape != null) {
      int maxSafeChar=MAX_UTF_MAPPABLE_CODEPOINT;
      if (encoding != null) {
        if (encoding.equalsIgnoreCase("String_Node_Str") || encoding.equalsIgnoreCase("String_Node_Str")) {
          maxSafeChar=MAX_ASCII_MAPPABLE_CODEPOINT;
        }
 else         if (encoding.equalsIgnoreCase("String_Node_Str")) {
          maxSafeChar=MAX_LATIN1_MAPPABLE_CODEPOINT;
        }
      }
      escape.setMappingLimit(maxSafeChar);
      if (!"String_Node_Str".equals(xmlVersion)) {
        escape.setAllowControlCharacters(true);
      }
    }
  }
 else {
    if (handler instanceof DefaultDOMHandlerImpl) {
      ((DefaultDOMHandlerImpl)handler).setExtendedMetaData(extendedMetaData);
    }
  }
  processDanglingHREF=(String)options.get(XMLResource.OPTION_PROCESS_DANGLING_HREF);
  helper.setProcessDanglingHREF(processDanglingHREF);
  map=(XMLResource.XMLMap)options.get(XMLResource.OPTION_XML_MAP);
  if (map != null) {
    helper.setXMLMap(map);
    if (map.getIDAttributeName() != null) {
      idAttributeName=map.getIDAttributeName();
    }
  }
  if (resource != null) {
    eObjectToExtensionMap=resource.getEObjectToExtensionMap();
    if (eObjectToExtensionMap.isEmpty()) {
      eObjectToExtensionMap=null;
    }
 else     if (extendedMetaData == null) {
      extendedMetaData=resource.getResourceSet() == null ? ExtendedMetaData.INSTANCE : new BasicExtendedMetaData(resource.getResourceSet().getPackageRegistry());
    }
  }
  if (extendedMetaData != null) {
    helper.setExtendedMetaData(extendedMetaData);
    if (resource != null && resource.getContents().size() >= 1) {
      EObject root=(EObject)resource.getContents().get(0);
      EClass eClass=root.eClass();
      EReference xmlnsPrefixMapFeature=extendedMetaData.getXMLNSPrefixMapFeature(eClass);
      if (xmlnsPrefixMapFeature != null) {
        EMap xmlnsPrefixMap=(EMap)root.eGet(xmlnsPrefixMapFeature);
        helper.setPrefixToNamespaceMap(xmlnsPrefixMap);
      }
    }
  }
  List lookup=(List)options.get(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE);
  if (lookup != null) {
    if (lookup.isEmpty()) {
      featureTable=new Lookup(map,extendedMetaData);
      lookup.add(featureTable);
    }
 else {
      featureTable=(Lookup)lookup.get(INDEX_LOOKUP);
    }
  }
 else {
    featureTable=new Lookup(map,extendedMetaData);
  }
}

Fixed version (ground truth):
protected void init(XMLResource resource,Map options){
  useCache=Boolean.TRUE.equals(options.get(XMLResource.OPTION_CONFIGURATION_CACHE));
  nameInfo=new NameInfoImpl();
  declareXSI=false;
  keepDefaults=Boolean.TRUE.equals(options.get(XMLResource.OPTION_KEEP_DEFAULT_CONTENT));
  useEncodedAttributeStyle=Boolean.TRUE.equals(options.get(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE));
  declareSchemaLocationImplementation=Boolean.TRUE.equals(options.get(XMLResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION));
  declareSchemaLocation=declareSchemaLocationImplementation || Boolean.TRUE.equals(options.get(XMLResource.OPTION_SCHEMA_LOCATION));
  Object saveTypeInfoOption=options.get(XMLResource.OPTION_SAVE_TYPE_INFORMATION);
  if (saveTypeInfoOption instanceof Boolean) {
    saveTypeInfo=saveTypeInfoOption.equals(Boolean.TRUE);
    if (saveTypeInfo) {
      xmlTypeInfo=new XMLTypeInfo(){
        public boolean shouldSaveType(        EClass objectType,        EClassifier featureType,        EStructuralFeature feature){
          return objectType != anyType;
        }
        public boolean shouldSaveType(        EClass objectType,        EClass featureType,        EStructuralFeature feature){
          return true;
        }
      }
;
    }
  }
 else {
    saveTypeInfo=saveTypeInfoOption != null;
    if (saveTypeInfo) {
      xmlTypeInfo=(XMLTypeInfo)saveTypeInfoOption;
    }
  }
  anyType=(EClass)options.get(XMLResource.OPTION_ANY_TYPE);
  anySimpleType=(EClass)options.get(XMLResource.OPTION_ANY_SIMPLE_TYPE);
  if (anyType == null) {
    anyType=XMLTypePackage.eINSTANCE.getAnyType();
    anySimpleType=XMLTypePackage.eINSTANCE.getSimpleAnyType();
  }
  Object extendedMetaDataOption=options.get(XMLResource.OPTION_EXTENDED_META_DATA);
  if (extendedMetaDataOption instanceof Boolean) {
    if (extendedMetaDataOption.equals(Boolean.TRUE)) {
      extendedMetaData=resource == null || resource.getResourceSet() == null ? ExtendedMetaData.INSTANCE : new BasicExtendedMetaData(resource.getResourceSet().getPackageRegistry());
    }
  }
 else {
    extendedMetaData=(ExtendedMetaData)options.get(XMLResource.OPTION_EXTENDED_META_DATA);
  }
  if (!toDOM) {
    declareXML=!Boolean.FALSE.equals(options.get(XMLResource.OPTION_DECLARE_XML));
    if (options.get(XMLResource.OPTION_FLUSH_THRESHOLD) instanceof Integer) {
      flushThreshold=((Integer)options.get(XMLResource.OPTION_FLUSH_THRESHOLD)).intValue();
    }
    String temporaryFileName=null;
    if (Boolean.TRUE.equals(options.get(XMLResource.OPTION_USE_FILE_BUFFER))) {
      try {
        temporaryFileName=File.createTempFile("String_Node_Str",null).getPath();
      }
 catch (      IOException exception) {
      }
    }
    Integer lineWidth=(Integer)options.get(XMLResource.OPTION_LINE_WIDTH);
    int effectiveLineWidth=lineWidth == null ? Integer.MAX_VALUE : lineWidth.intValue();
    String publicId=null, systemId=null;
    if (resource != null && Boolean.TRUE.equals(options.get(XMLResource.OPTION_SAVE_DOCTYPE))) {
      publicId=resource.getPublicId();
      systemId=resource.getSystemId();
    }
    if (useCache) {
      doc=ConfigurationCache.INSTANCE.getPrinter();
      doc.reset(publicId,systemId,effectiveLineWidth,temporaryFileName);
      escape=Boolean.TRUE.equals(options.get(XMLResource.OPTION_SKIP_ESCAPE)) ? null : ConfigurationCache.INSTANCE.getEscape();
    }
 else {
      doc=new XMLString(effectiveLineWidth,publicId,systemId,temporaryFileName);
      escape=Boolean.TRUE.equals(options.get(XMLResource.OPTION_SKIP_ESCAPE)) ? null : new Escape();
    }
    if (Boolean.FALSE.equals(options.get(XMLResource.OPTION_FORMATTED))) {
      doc.setUnformatted(true);
    }
    escapeURI=Boolean.FALSE.equals(options.get(XMLResource.OPTION_SKIP_ESCAPE_URI)) ? escape : null;
    if (options.containsKey(XMLResource.OPTION_ENCODING)) {
      encoding=(String)options.get(XMLResource.OPTION_ENCODING);
    }
 else     if (resource != null) {
      encoding=resource.getEncoding();
    }
    if (options.containsKey(XMLResource.OPTION_XML_VERSION)) {
      xmlVersion=(String)options.get(XMLResource.OPTION_XML_VERSION);
    }
 else     if (resource != null) {
      xmlVersion=resource.getXMLVersion();
    }
    if (escape != null) {
      int maxSafeChar=MAX_UTF_MAPPABLE_CODEPOINT;
      if (encoding != null) {
        if (encoding.equalsIgnoreCase("String_Node_Str") || encoding.equalsIgnoreCase("String_Node_Str")) {
          maxSafeChar=MAX_ASCII_MAPPABLE_CODEPOINT;
        }
 else         if (encoding.equalsIgnoreCase("String_Node_Str")) {
          maxSafeChar=MAX_LATIN1_MAPPABLE_CODEPOINT;
        }
      }
      escape.setMappingLimit(maxSafeChar);
      if (!"String_Node_Str".equals(xmlVersion)) {
        escape.setAllowControlCharacters(true);
      }
    }
  }
 else {
    if (handler instanceof DefaultDOMHandlerImpl) {
      ((DefaultDOMHandlerImpl)handler).setExtendedMetaData(extendedMetaData);
    }
  }
  processDanglingHREF=(String)options.get(XMLResource.OPTION_PROCESS_DANGLING_HREF);
  helper.setProcessDanglingHREF(processDanglingHREF);
  map=(XMLResource.XMLMap)options.get(XMLResource.OPTION_XML_MAP);
  if (map != null) {
    helper.setXMLMap(map);
    if (map.getIDAttributeName() != null) {
      idAttributeName=map.getIDAttributeName();
    }
  }
  if (resource != null) {
    eObjectToExtensionMap=resource.getEObjectToExtensionMap();
    if (eObjectToExtensionMap.isEmpty()) {
      eObjectToExtensionMap=null;
    }
 else     if (extendedMetaData == null) {
      extendedMetaData=resource.getResourceSet() == null ? ExtendedMetaData.INSTANCE : new BasicExtendedMetaData(resource.getResourceSet().getPackageRegistry());
    }
  }
  if (extendedMetaData != null) {
    helper.setExtendedMetaData(extendedMetaData);
    if (resource != null && resource.getContents().size() >= 1) {
      EObject root=(EObject)resource.getContents().get(0);
      EClass eClass=root.eClass();
      EReference xmlnsPrefixMapFeature=extendedMetaData.getXMLNSPrefixMapFeature(eClass);
      if (xmlnsPrefixMapFeature != null) {
        EMap xmlnsPrefixMap=(EMap)root.eGet(xmlnsPrefixMapFeature);
        helper.setPrefixToNamespaceMap(xmlnsPrefixMap);
      }
    }
  }
  List lookup=(List)options.get(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE);
  if (lookup != null) {
    if (lookup.isEmpty()) {
      featureTable=new Lookup(map,extendedMetaData);
      lookup.add(featureTable);
    }
 else {
      featureTable=(Lookup)lookup.get(INDEX_LOOKUP);
    }
  }
 else {
    featureTable=new Lookup(map,extendedMetaData);
  }
}