blob: 67a7d48c663060d4c0e86c2939278e40a767c7f9 [file] [log] [blame]
/**
* <copyright>
* Copyright (c) 2010 Mia-Software.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*
* Nicolas Guyomar (Mia-Software) - initial API and implementation
* </copyright>
*
* $Id$
*/
package org.eclipse.modisco.jee.webapp.webapp30.util;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.XMLResource.URIHandler;
/**
* <!-- begin-user-doc --> The <b>Resource Factory</b> associated with the
* package. <!-- end-user-doc -->
* @see org.eclipse.modisco.jee.webapp.webapp30.util.Webapp30ResourceImpl
* @generated
*/
public class Webapp30ResourceFactoryImpl extends ResourceFactoryImpl {
/**
* Creates an instance of the resource factory.
* <!-- begin-user-doc --> <!--
* end-user-doc -->
* @generated
*/
public Webapp30ResourceFactoryImpl() {
super();
}
/**
* Creates an instance of the resource. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @generated NOT
*/
@Override
public Resource createResource(final URI uri) {
XMLResource result = new Webapp30ResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
// This option prevent XMLReader raise exception on unknown feature
result.getDefaultLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
// see /model/readme.txt about uris management
URIHandler localUriHandler = new MoDiscoURIHandler();
result.getDefaultLoadOptions().put(XMLResource.OPTION_URI_HANDLER, localUriHandler);
result.getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER, localUriHandler);
return result;
}
// see /model/readme.txt about uris management
class MoDiscoURIHandler implements URIHandler {
private final URI jeeStandardURI = URI
.createURI("http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd");
private final URI modiscoSubstituteURI = URI
.createURI("http://www.eclipse.org/MoDisco/Javaee/web-app_3_0.xsd");
public void setBaseURI(final URI uri) {
// Nothing
}
public URI resolve(final URI uri) {
if (uri.equals(this.jeeStandardURI)) {
return this.modiscoSubstituteURI;
}
return uri;
}
public URI deresolve(final URI uri) {
if (uri.equals(this.modiscoSubstituteURI)) {
return this.jeeStandardURI;
}
return uri;
}
}
} // Webapp30ResourceFactoryImpl