com.tek42.perforce.parse
Class CounterBuilder

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

public class CounterBuilder
extends java.lang.Object
implements Builder<Counter>

Responsible for building and saving counters.

Author:
Kamlesh Sangani

Constructor Summary
CounterBuilder()
           
 
Method Summary
 Counter build(java.lang.StringBuilder sb)
          This should assemble an object from a string value.
 java.lang.String[] getBuildCmd(java.lang.String p4exe, java.lang.String id)
          This should return the command line tokens to execute for retrieving an object from Perforce.
 java.lang.String[] getSaveCmd(java.lang.String p4exe, Counter obj)
          The converse of #getBuildCmd(String) this should return the command line tokens to execute for saving an object to Perforce.
 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(Counter counter, java.io.Writer writer)
          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

CounterBuilder

public CounterBuilder()
Method Detail

getBuildCmd

public java.lang.String[] getBuildCmd(java.lang.String p4exe,
                                      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<Counter>
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.

getSaveCmd

public java.lang.String[] getSaveCmd(java.lang.String p4exe,
                                     Counter obj)
Description copied from interface: Builder
The converse of #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<Counter>
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

build

public Counter 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<Counter>
Parameters:
sb - The StringBuilder containing the string value.
Returns:
The resulting object
Throws:
PerforceException - If the format is invalid or other errors occur.

save

public void save(Counter counter,
                 java.io.Writer writer)
          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<Counter>
Parameters:
counter - The object to be saved
writer - The Writer to write the string representation to
Throws:
PerforceException - If the object is invalid or there is an issue with writing

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<Counter>
Returns:
True if standard input should be opened and this builder's save() method called. False otherwise.


Copyright © 2010. All Rights Reserved.