Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.project
Class ProjectFile

    java.lang.Object
      org.apache.cayenne.project.ProjectFile

Direct Known Subclasses:
  ApplicationProjectFile, DataMapFile, DataNodeFile

    public abstract class ProjectFile

extends java.lang.Object

ProjectFile is an adapter from an object in Cayenne project to its representation in the file system.

Author:
  Andrei Adamchik

Field Summary
`protected java.lang.String` | `location`
`protected Project` | `projectObj`
`protected java.io.File` | `tempFile`

Constructor Summary
`ProjectFile()`
`ProjectFile(Project project, java.lang.String location)` Constructor for ProjectFile.

Method Summary
`abstract boolean` | `canHandle(java.lang.Object obj)` Returns true if this file wrapper can handle a specified object.
`boolean` | `canHandleObject()` Returns true if this file wrapper can handle an internally stored object.
`protected void` | `checkWritePermissions(java.io.File file)`
`java.lang.String` | `getLocation()` Builds a filename from the object name and "file suffix".
`java.lang.String` | `getLocationSuffix()` Returns suffix to append to object name when creating a file name.
`abstract java.lang.Object` | `getObject()` Returns a project object associated with this file.
`abstract java.lang.String` | `getObjectName()` Returns a name of associated object, that is also used as a file name.
`java.lang.String` | `getOldLocation()` Returns saved location of a file.
`Project` | `getProject()` Returns the project.
`boolean` | `isRenamed()`
`java.io.File` | `resolveFile()` Returns a file which is a canonical representation of the file to store a wrapped object.
`java.io.File` | `resolveOldFile()` Returns a file which is a canonical representation of the file to store a wrapped object.
`abstract void` | `save(java.io.PrintWriter out)` Saves an underlying object to the file.
`java.io.File` | `saveCommit()` Finishes saving the underlying object.
`void` | `saveTemp()` Saves ProjectFile's underlying object to a temporary file, returning this file to the caller.
`void` | `saveUndo()` Cleans up after unsuccessful or canceled save attempt.
`void` | `synchronizeLocation()` Replaces internally stored filename with the current object name.
`protected java.io.File` | `tempFileForFile(java.io.File f)` Creates a temporary file for the master file.
`java.lang.String` | `toString()`
`void` | `willSave()` This method is called by project to let file know that it will be saved.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### location

    protected java.lang.String location

### tempFile

    protected java.io.File tempFile

### projectObj

    protected Project projectObj

Constructor Detail

### ProjectFile

    public ProjectFile()

### ProjectFile

    public ProjectFile(Project project,
                       java.lang.String location)

  Constructor for ProjectFile.

Method Detail

### getLocation

    public java.lang.String getLocation()

  Builds a filename from the object name and "file suffix".

### getOldLocation

    public java.lang.String getOldLocation()

  Returns saved location of a file.

### getLocationSuffix

    public java.lang.String getLocationSuffix()

  Returns suffix to append to object name when creating a file name. Default implementation returns empty string.

### getObject

    public abstract java.lang.Object getObject()

  Returns a project object associated with this file.

### getObjectName

    public abstract java.lang.String getObjectName()

  Returns a name of associated object, that is also used as a file name.

### save

    public abstract void save(java.io.PrintWriter out)
                       throws java.lang.Exception

  Saves an underlying object to the file. The procedure is dependent on the type of object and is implemented by concrete subclasses.

  Throws:
    `java.lang.Exception`

### canHandle

    public abstract boolean canHandle(java.lang.Object obj)

  Returns true if this file wrapper can handle a specified object.

### canHandleObject

    public boolean canHandleObject()

  Returns true if this file wrapper can handle an internally stored object.

### synchronizeLocation

    public void synchronizeLocation()

  Replaces internally stored filename with the current object name.

### willSave

    public void willSave()

  This method is called by project to let file know that it will be saved. Default implementation is a noop.

### saveTemp

    public void saveTemp()
                  throws java.lang.Exception

  Saves ProjectFile's underlying object to a temporary file, returning this file to the caller. If any problems are encountered during saving, an Exception is thrown.

  Throws:
    `java.lang.Exception`

### resolveFile

    public java.io.File resolveFile()

  Returns a file which is a canonical representation of the file to store a wrapped object. If an object was renamed, the new name is returned.

### resolveOldFile

    public java.io.File resolveOldFile()

  Returns a file which is a canonical representation of the file to store a wrapped object. If an object was renamed, the old name is returned. Returns null if this file has never been saved before.

### saveCommit

    public java.io.File saveCommit()
                            throws ProjectException

  Finishes saving the underlying object.

  Throws:
    `ProjectException`

### saveUndo

    public void saveUndo()

  Cleans up after unsuccessful or canceled save attempt.

### getProject

    public Project getProject()

  Returns the project.

  Returns:
    Project

### isRenamed

    public boolean isRenamed()

### tempFileForFile

    protected java.io.File tempFileForFile(java.io.File f)
                                    throws java.io.IOException

  Creates a temporary file for the master file.

  Throws:
    `java.io.IOException`

### checkWritePermissions

    protected void checkWritePermissions(java.io.File file)
                                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 Apache.org All Rights Reserved.