use of org.eclipse.mylyn.docs.epub.opf.OPFPackage in project mylyn.docs by eclipse.
the class Publication method registerOPFResourceFactory.
/**
* Registers a new resource factory for OPF data structures. This is normally done through Eclipse extension points
* but we also need to be able to create this factory without the Eclipse runtime.
*/
private void registerOPFResourceFactory() {
// Register package so that it is available even without the Eclipse runtime
@SuppressWarnings("unused") OPFPackage packageInstance = OPFPackage.eINSTANCE;
// Register the file suffix
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(OPF_FILE_SUFFIX, new XMLResourceFactoryImpl() {
@Override
public Resource createResource(URI uri) {
OPFResourceImpl xmiResource = new OPFResourceImpl(uri) {
@Override
protected XMLHelper createXMLHelper() {
EPUBXMLHelperImp xmlHelper = new EPUBXMLHelperImp();
return xmlHelper;
}
};
Map<Object, Object> loadOptions = xmiResource.getDefaultLoadOptions();
Map<Object, Object> saveOptions = xmiResource.getDefaultSaveOptions();
// We use extended metadata
saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
loadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
// Required in order to correctly read in attributes
loadOptions.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE);
// Treat "href" attributes as features
loadOptions.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
// UTF-8 encoding is required per specification
saveOptions.put(XMLResource.OPTION_ENCODING, XML_ENCODING);
// Do not download any external DTDs.
Map<String, Object> parserFeatures = new HashMap<String, Object>();
// $NON-NLS-1$
parserFeatures.put("http://xml.org/sax/features/validation", Boolean.FALSE);
// $NON-NLS-1$
parserFeatures.put(// $NON-NLS-1$
"http://apache.org/xml/features/nonvalidating/load-external-dtd", Boolean.FALSE);
loadOptions.put(XMLResource.OPTION_PARSER_FEATURES, parserFeatures);
return xmiResource;
}
});
}
use of org.eclipse.mylyn.docs.epub.opf.OPFPackage in project mylyn.docs by eclipse.
the class DCPackageImpl method initializePackageContents.
/**
* Complete the initialization of the package and its meta-model. This
* method is guarded to have no affect on any invocation but its first.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void initializePackageContents() {
if (isInitialized)
return;
isInitialized = true;
// Initialize package
setName(eNAME);
setNsPrefix(eNS_PREFIX);
setNsURI(eNS_URI);
// Obtain other dependent packages
OPFPackage theOPFPackage = (OPFPackage) EPackage.Registry.INSTANCE.getEPackage(OPFPackage.eNS_URI);
// Create type parameters
// Set bounds for type parameters
// Add supertypes to classes
titleEClass.getESuperTypes().add(this.getLocalizedDCType());
creatorEClass.getESuperTypes().add(this.getLocalizedDCType());
subjectEClass.getESuperTypes().add(this.getLocalizedDCType());
descriptionEClass.getESuperTypes().add(this.getLocalizedDCType());
publisherEClass.getESuperTypes().add(this.getLocalizedDCType());
contributorEClass.getESuperTypes().add(this.getLocalizedDCType());
dateEClass.getESuperTypes().add(this.getDCType());
typeEClass.getESuperTypes().add(this.getDCType());
formatEClass.getESuperTypes().add(this.getDCType());
sourceEClass.getESuperTypes().add(this.getLocalizedDCType());
languageEClass.getESuperTypes().add(this.getDCType());
relationEClass.getESuperTypes().add(this.getLocalizedDCType());
coverageEClass.getESuperTypes().add(this.getLocalizedDCType());
rightsEClass.getESuperTypes().add(this.getLocalizedDCType());
localizedDCTypeEClass.getESuperTypes().add(this.getDCType());
// Initialize classes and features; add operations and parameters
// $NON-NLS-1$
initEClass(titleEClass, Title.class, "Title", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(creatorEClass, Creator.class, "Creator", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEAttribute(getCreator_Role(), theOPFPackage.getRole(), "role", null, 0, 1, Creator.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEAttribute(getCreator_FileAs(), ecorePackage.getEString(), "fileAs", null, 0, 1, Creator.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEClass(subjectEClass, Subject.class, "Subject", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(descriptionEClass, Description.class, "Description", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(publisherEClass, Publisher.class, "Publisher", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(contributorEClass, Contributor.class, "Contributor", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEAttribute(getContributor_Role(), theOPFPackage.getRole(), "role", null, 0, 1, Contributor.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEAttribute(getContributor_FileAs(), ecorePackage.getEString(), "fileAs", null, 0, 1, Contributor.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEClass(dateEClass, Date.class, "Date", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEAttribute(getDate_Event(), ecorePackage.getEString(), "event", null, 0, 1, Date.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEClass(typeEClass, Type.class, "Type", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(formatEClass, Format.class, "Format", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(identifierEClass, Identifier.class, "Identifier", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$ //$NON-NLS-2$
initEAttribute(getIdentifier_Id(), ecorePackage.getEString(), "id", "BookId", 1, 1, Identifier.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEAttribute(getIdentifier_Scheme(), ecorePackage.getEString(), "scheme", null, 0, 1, Identifier.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEAttribute(getIdentifier_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 1, -1, Identifier.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEClass(sourceEClass, Source.class, "Source", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(languageEClass, Language.class, "Language", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEAttribute(getLanguage_Type(), ecorePackage.getEString(), "type", null, 0, 1, Language.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEClass(relationEClass, Relation.class, "Relation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(coverageEClass, Coverage.class, "Coverage", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(rightsEClass, Rights.class, "Rights", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEClass(dcTypeEClass, DCType.class, "DCType", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEAttribute(getDCType_Id(), ecorePackage.getEString(), "id", null, 0, 1, DCType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEAttribute(getDCType_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 1, -1, DCType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// $NON-NLS-1$
initEClass(localizedDCTypeEClass, LocalizedDCType.class, "LocalizedDCType", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
// $NON-NLS-1$
initEAttribute(getLocalizedDCType_Lang(), ecorePackage.getEString(), "lang", null, 0, 1, LocalizedDCType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// Create resource
createResource(eNS_URI);
// Create annotations
// http:///org/eclipse/emf/ecore/util/ExtendedMetaData
createExtendedMetaDataAnnotations();
}
Aggregations