Dali Provisional API
Release 3.2

org.eclipse.jpt.common.core.resource.xml
Class JptXmlResource

java.lang.Object
  extended by TranslatorResourceImpl
      extended by org.eclipse.jpt.common.core.resource.xml.JptXmlResource
All Implemented Interfaces:
ContentTypeReference, JptResourceModel, JptResourceTypeReference

public class JptXmlResource
extends TranslatorResourceImpl
implements JptResourceModel, ContentTypeReference

To retrieve the JPA XML resource corresponding to an Eclipse file:

 IFile file = (IFile) ResourcesPlugin.getWorkspace().getRoot().findMember("Foo.java");
 JptXmlResource jpaXmlResource = (JptXmlResource) file.getAdapter(JptXmlResource.class);
 
This is a non-blocking call; and as a result it will return null if the JPA XML resource or its JPA project is currently under construction.

See org.eclipse.jpt.jpa.core/plugin.xml:org.eclipse.core.runtime.adapters.

Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

Since:
2.2

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.jpt.common.core.JptResourceTypeReference
JptResourceTypeReference.ResourceTypeIsKindOf, JptResourceTypeReference.ResourceTypeTransformer
 
Nested classes/interfaces inherited from interface org.eclipse.jpt.common.core.ContentTypeReference
ContentTypeReference.ContentTypeIs, ContentTypeReference.ContentTypeIsKindOf, ContentTypeReference.ContentTypeTransformer
 
Field Summary
protected  IContentType contentType
          cache the content type - if the content type changes, the JPA project will throw out the JPA file holding the xml resource and build a new one
protected  org.eclipse.jpt.common.utility.internal.ListenerList<JptResourceModelListener> resourceModelListenerList
           
protected  Translator rootTranslator
           
 
Fields inherited from interface org.eclipse.jpt.common.core.JptResourceTypeReference
TRANSFORMER
 
Fields inherited from interface org.eclipse.jpt.common.core.ContentTypeReference
TRANSFORMER
 
Constructor Summary
JptXmlResource(URI uri, Renderer renderer, IContentType contentType, Translator rootTranslator)
           
 
Method Summary
 void addResourceModelListener(JptResourceModelListener listener)
          Changes to the resource model result in events.
 EList<Adapter> eAdapters()
           
 void eNotify(Notification notification)
          Override to fire notification only when: the resource's state has actually changed; and the resource is loaded; and the resource's resource set is still present (EMF will fire an notification when the resource set is set to 'null', just before the resource is "unloaded" - we want to swallow this notification)
 boolean fileExists()
           
 EList<EObject> getContents()
           
 IContentType getContentType()
          Return an Eclipse content type.
protected  IFile getConvertedURIFile()
           
protected  String getDefaultPublicId()
          only applicable for DTD-based files
protected  String getDefaultSystemId()
          only applicable for DTD-based files
protected  int getDefaultVersionID()
          this seems to be the default version of the spec for this doc and the id 10 maps to the version 1.0
 String getDoctype()
          only applicable for DTD-based files
 EntityResolver getEntityResolver()
           
 IFile getFile()
          Return the model's file.
protected  IFile getFile(URI fileURI)
          Return the Eclipse file for the specified URI.
 JptResourceType getResourceType()
          The XML schema version is required.
protected  JptResourceType getResourceType(String version)
           
 org.eclipse.jpt.common.core.resource.xml.ERootObject getRootObject()
           
 Translator getRootTranslator()
           
 String getVersion()
           
protected  boolean loadedFlagCleared(Notification notification)
          Return whether the specified notification indicates the resource has been unloaded.
 void removeResourceModelListener(JptResourceModelListener listener)
           
protected  void resourceModelChanged()
           
protected  void resourceModelReverted()
           
protected  void resourceModelUnloaded()
           
protected  boolean resultSetCleared(Notification notification)
          Return whether the specified notification indicates the resource's resource set was cleared.
 void save()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

contentType

protected final IContentType contentType
cache the content type - if the content type changes, the JPA project will throw out the JPA file holding the xml resource and build a new one


rootTranslator

protected final Translator rootTranslator

resourceModelListenerList

protected final org.eclipse.jpt.common.utility.internal.ListenerList<JptResourceModelListener> resourceModelListenerList
Constructor Detail

JptXmlResource

public JptXmlResource(URI uri,
                      Renderer renderer,
                      IContentType contentType,
                      Translator rootTranslator)
Method Detail

getContentType

public IContentType getContentType()
Description copied from interface: ContentTypeReference
Return an Eclipse content type.

Specified by:
getContentType in interface ContentTypeReference

getVersion

public String getVersion()

getResourceType

public JptResourceType getResourceType()
The XML schema version is required.

Specified by:
getResourceType in interface JptResourceTypeReference

getResourceType

protected JptResourceType getResourceType(String version)

eNotify

public void eNotify(Notification notification)
Override to fire notification only when:


loadedFlagCleared

protected boolean loadedFlagCleared(Notification notification)
Return whether the specified notification indicates the resource has been unloaded. we could use this method to suppress some notifications; or we could just check whether 'resourceSet' is 'null' (which is what we do)


resultSetCleared

protected boolean resultSetCleared(Notification notification)
Return whether the specified notification indicates the resource's resource set was cleared. We could use this method to suppress some resource set notifications; or we could just check whether resourceSet is null (which is what we do)/


getDoctype

public String getDoctype()
only applicable for DTD-based files


getRootTranslator

public Translator getRootTranslator()

getDefaultPublicId

protected String getDefaultPublicId()
only applicable for DTD-based files


getDefaultSystemId

protected String getDefaultSystemId()
only applicable for DTD-based files


getDefaultVersionID

protected int getDefaultVersionID()
this seems to be the default version of the spec for this doc and the id 10 maps to the version 1.0


getRootObject

public org.eclipse.jpt.common.core.resource.xml.ERootObject getRootObject()

getEntityResolver

public EntityResolver getEntityResolver()

fileExists

public boolean fileExists()

getFile

public IFile getFile()
Description copied from interface: JptResourceModel
Return the model's file.

Specified by:
getFile in interface JptResourceModel

getConvertedURIFile

protected IFile getConvertedURIFile()

getFile

protected IFile getFile(URI fileURI)
Return the Eclipse file for the specified URI. This URI is assumed to be absolute in the following format:
     platform:/resource/....
 


save

public void save()

toString

public String toString()

addResourceModelListener

public void addResourceModelListener(JptResourceModelListener listener)
Description copied from interface: JptResourceModel
Changes to the resource model result in events. In particular, the JPA project performs an "update" whenever a resource model changes.

Specified by:
addResourceModelListener in interface JptResourceModel

removeResourceModelListener

public void removeResourceModelListener(JptResourceModelListener listener)
Specified by:
removeResourceModelListener in interface JptResourceModel
See Also:
JptResourceModel.addResourceModelListener(JptResourceModelListener)

resourceModelChanged

protected void resourceModelChanged()

resourceModelReverted

protected void resourceModelReverted()

resourceModelUnloaded

protected void resourceModelUnloaded()

eAdapters

public EList<Adapter> eAdapters()

getContents

public EList<EObject> getContents()

Dali Provisional API
Release 3.2

Copyright (c) 2012 Oracle. All rights reserved.