com.tek42.perforce.parse
Class ChangelistBuilder

java.lang.Object
  extended by com.tek42.perforce.parse.ChangelistBuilder
All Implemented Interfaces:
Builder<Changelist>

public class ChangelistBuilder
extends java.lang.Object
implements Builder<Changelist>

Responsible for building and saving changelists.

Author:
Mike Wille

Constructor Summary
ChangelistBuilder()
           
 
Method Summary
 Changelist build(java.lang.StringBuilder sb)
          This should assemble an object from a string value.
 java.lang.String[] getBuildCmd(java.lang.String id)
          This should return the command line tokens to execute for retrieving an object from Perforce.
 java.lang.String[] getSaveCmd(Changelist obj)
          The converse of Builder.getBuildCmd(String) this should return the command line tokens to execute for saving an object to Perforce.
static java.util.Date parseDate(java.lang.String newDate)
          Returns a java.util.Date object set to the time specified in newDate.
 boolean requiresStandardInput()
          Tells the AbstractPerforceTemplate whether or not this builder will write data on Standard Input to the perforce command specified in getSaveCmd().
 void save(Changelist obj, java.io.Writer out)
          The converse of Builder.build(StringBuilder) this should take an object and disassemble it for writing to the Perforce server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangelistBuilder

public ChangelistBuilder()
Method Detail

getBuildCmd

public java.lang.String[] getBuildCmd(java.lang.String id)
Description copied from interface: Builder
This should return the command line tokens to execute for retrieving an object from Perforce. For example: String[] { "p4", "user", "-o", "mwille" }

Specified by:
getBuildCmd in interface Builder<Changelist>
Parameters:
id - The ID or Name of the object we are working on. In the case of a changelist, the changelist number. In the case of a user, the username.
Returns:
A 1D string array of tokens to execute.

build

public Changelist build(java.lang.StringBuilder sb)
                 throws PerforceException
Description copied from interface: Builder
This should assemble an object from a string value. Format of the string is dependent on the object we are building and is unspecified.

Specified by:
build in interface Builder<Changelist>
Parameters:
sb - The StringBuilder containing the string value.
Returns:
The resulting object
Throws:
PerforceException - If the format is invalid or other errors occur.

getSaveCmd

public java.lang.String[] getSaveCmd(Changelist obj)
Description copied from interface: Builder
The converse of Builder.getBuildCmd(String) this should return the command line tokens to execute for saving an object to Perforce. For example: String[] { "p4", "user", "-i", "mwille" }

Note, although the object being saved is passed to this method, this method does not need to do anything with it.

Specified by:
getSaveCmd in interface Builder<Changelist>
Parameters:
obj - The object that is being saved, useful if propert(ies) are needed for the save command to be generated.
Returns:
A 1D string array of tokens to execute

requiresStandardInput

public boolean requiresStandardInput()
Description copied from interface: Builder
Tells the AbstractPerforceTemplate whether or not this builder will write data on Standard Input to the perforce command specified in getSaveCmd(). Currently, this only applies to saving as their is no writing required for building.

Specified by:
requiresStandardInput in interface Builder<Changelist>
Returns:
True if standard input should be opened and this builder's save() method called. False otherwise.

save

public void save(Changelist obj,
                 java.io.Writer out)
          throws PerforceException
Description copied from interface: Builder
The converse of Builder.build(StringBuilder) this should take an object and disassemble it for writing to the Perforce server. The specification of what is written to the Writer is dependant on the object being saved.

Specified by:
save in interface Builder<Changelist>
Parameters:
obj - The object to be saved
out - The Writer to write the string representation to
Throws:
PerforceException - If the object is invalid or there is an issue with writing

parseDate

public static java.util.Date parseDate(java.lang.String newDate)
Returns a java.util.Date object set to the time specified in newDate. The format expected is the format of: YYYY-MM-DD HH:MM:SS

Parameters:
newDate - the string date to convert
Returns:
A java.util.Date based off of the string format.


Copyright © 2010. All Rights Reserved.