com.partnersoft.codex
Class CodexResource
java.lang.Object
com.partnersoft.codex.CodexResource
- All Implemented Interfaces:
- CodexNode
public class CodexResource
- extends java.lang.Object
- implements CodexNode
Editing
(brain not working)
We diverge from the standard model-view-controller pattern by having two different models
for a resource: cogs and text. This wouldn't be a problem if we were using "save the entire
resource" edits, because then the cog model and the text model could just regenerate themselves
whenever the resource changed. However, instead of a handful of "save the entire resource"
edits, we have lots of little micro-edits.
Every keystroke in the text editor can't regenerate the cog model, and every changed
field in the cog editor can't regenerate the text, because the application would be
swamped with pointeless model regeneration. Instead, we use lazy evaluation to only
generate the models we need as we need them. As a model is edited, it notifies the
resource through touch(). When the resource needs to know what its bytes are, it asks
the touching model through CodexResourceModel.save().
- Author:
- Russell Cagle
Copyright 2006 Partner Software, Inc.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
lastModified
protected long lastModified
lastModifiedOnDisk
protected long lastModifiedOnDisk
CodexResource
protected CodexResource(CodexSection section,
java.lang.String name,
java.lang.Class[] modelClasses)
throws java.io.IOException
- Throws:
java.io.IOException
createFile
public java.io.File createFile()
getModel
public CodexResourceModel getModel(java.lang.String type)
getModel
public <T extends CodexResourceModel> T getModel(java.lang.Class<T> clazz)
commit
public void commit()
throws java.io.IOException
- Writes any pending changes to disk.
- Throws:
java.io.IOException
deleteResource
public void deleteResource()
throws java.io.IOException
- Throws:
java.io.IOException
getBytes
public byte[] getBytes()
throws java.io.IOException
- If the resource has been touched (see touch(), CodexResourceModel), then this gets the new
bytes from the model.
- Returns:
-
- Throws:
java.io.IOException
getWorkspace
public Workspace getWorkspace()
- Specified by:
getWorkspace in interface CodexNode
getCodex
public Codex getCodex()
- Specified by:
getCodex in interface CodexNode
getCodexSection
public CodexSection getCodexSection()
- Specified by:
getCodexSection in interface CodexNode
getCodexResource
public CodexResource getCodexResource()
- Specified by:
getCodexResource in interface CodexNode
getCodexParent
public CodexNode getCodexParent()
- Specified by:
getCodexParent in interface CodexNode
getLastModified
public long getLastModified()
getModels
public java.util.ArrayList<CodexResourceModel> getModels()
getCodexNodeViews
public java.util.List<CodexNodeView> getCodexNodeViews()
getName
public java.lang.String getName()
getCodexNodeName
public java.lang.String getCodexNodeName()
- Specified by:
getCodexNodeName in interface CodexNode
getPath
public Path getPath()
getSection
public CodexSection getSection()
removeModel
public void removeModel(CodexResourceModel model)
rename
public void rename(java.lang.String newName)
throws java.io.IOException
- Throws:
java.io.IOException
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
touch
public void touch(CodexResourceModel sourceModel)
- Invalidates everything but sourceModel.
Touch is meant to be a lightweight, quick operation, an operation
that can be called for every keystroke and mouse click.
- Parameters:
source -