Class Label
- java.lang.Object
-
- com.perforce.p4java.impl.generic.core.ServerResource
-
- com.perforce.p4java.impl.generic.core.LabelSummary
-
- com.perforce.p4java.impl.generic.core.Label
-
- All Implemented Interfaces:
ILabel
,ILabelSummary
,IServerResource
public class Label extends LabelSummary implements ILabel
Default implementation class for the ILabel interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Label.LabelMapping
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_DESCRIPTION
The description string used if no description field is passed to Label.newLabel().static java.lang.String
DEFAULT_MAPPING
The default mapping used if a null mapping parameter is passed to Label.newLabel().protected ViewMap<ILabelMapping>
viewMapping
-
Fields inherited from class com.perforce.p4java.impl.generic.core.LabelSummary
autoreload, AUTORELOAD_VALUE, description, lastAccess, lastUpdate, locked, LOCKED_VALUE, name, NOAUTORELOAD_VALUE, ownerName, revisionSpec, unloaded, UNLOCKED_VALUE
-
Fields inherited from class com.perforce.p4java.impl.generic.core.ServerResource
refreshable, server, updateable
-
-
Constructor Summary
Constructors Constructor Description Label()
Default constructor; sets all inherited and local fields to null or false; calls super(false).Label(ILabelSummary labelSummary)
Given an ILabelSummary object, construct a new Label object from it.Label(java.lang.String name, java.lang.String ownerName, java.util.Date lastAccess, java.util.Date lastUpdate, java.lang.String description, java.lang.String revisionSpec, boolean locked, ViewMap<ILabelMapping> viewMapping)
Explicit-value constructor.Label(java.util.Map<java.lang.String,java.lang.Object> map, IServer server)
Construct a new Label from the map passed back from the IServer's getLabel method or from a similar map, and the current server object (if any).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description IServer
getServer()
Get the Perforce server object associated with this label.ViewMap<ILabelMapping>
getViewMapping()
Get the view mapping for this label.static Label
newLabel(IServer server, java.lang.String name, java.lang.String description, java.lang.String[] mapping)
Create a new local Label object with the given name, description, and view mapping.void
refresh()
This method will refresh by getting the complete label model.void
setServer(IServer server)
Set the server associated with this resource.void
setViewMapping(ViewMap<ILabelMapping> viewMapping)
Set the view mapping for this label.void
update()
Update the Perforce server object associated with the underlying P4Java object, if possible.java.lang.String
updateOnServer()
Deprecated.use update() instead.-
Methods inherited from class com.perforce.p4java.impl.generic.core.LabelSummary
getDescription, getLastAccess, getLastUpdate, getName, getOwnerName, getRevisionSpec, isAutoReload, isLocked, isUnloaded, setAutoReload, setDescription, setLastAccess, setLastUpdate, setLocked, setName, setOwnerName, setRevisionSpec
-
Methods inherited from class com.perforce.p4java.impl.generic.core.ServerResource
canRefresh, canUpdate, clearRawFields, complete, getRawField, getRawFields, hasRawField, parseDate, setRawField, setRawFields, setRefreshable, toDateString, update, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.perforce.p4java.core.ILabelSummary
getDescription, getLastAccess, getLastUpdate, getName, getOwnerName, getRevisionSpec, isAutoReload, isLocked, isUnloaded, setAutoReload, setDescription, setLastAccess, setLastUpdate, setLocked, setName, setOwnerName, setRevisionSpec
-
Methods inherited from interface com.perforce.p4java.core.IServerResource
canRefresh, canUpdate, clearRawFields, complete, getRawField, getRawFields, hasRawField, setRawField, setRawFields, update, update
-
-
-
-
Field Detail
-
viewMapping
protected ViewMap<ILabelMapping> viewMapping
-
DEFAULT_DESCRIPTION
public static final java.lang.String DEFAULT_DESCRIPTION
The description string used if no description field is passed to Label.newLabel().- See Also:
- Constant Field Values
-
DEFAULT_MAPPING
public static final java.lang.String DEFAULT_MAPPING
The default mapping used if a null mapping parameter is passed to Label.newLabel().- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Label
public Label()
Default constructor; sets all inherited and local fields to null or false; calls super(false).
-
Label
public Label(java.lang.String name, java.lang.String ownerName, java.util.Date lastAccess, java.util.Date lastUpdate, java.lang.String description, java.lang.String revisionSpec, boolean locked, ViewMap<ILabelMapping> viewMapping)
Explicit-value constructor. Generally useful for constructing new label implementations.- Parameters:
name
- nameownerName
- ownerlastAccess
- datelastUpdate
- datedescription
- descriptionrevisionSpec
- revisionlocked
- lockedviewMapping
- view mapping
-
Label
public Label(java.util.Map<java.lang.String,java.lang.Object> map, IServer server)
Construct a new Label from the map passed back from the IServer's getLabel method or from a similar map, and the current server object (if any). Will not work properly with the map returned from the server getLabelSummaryList method.If the map is null, this is equivalent to calling the default constructor.
- Parameters:
map
- spec mapserver
- server
-
Label
public Label(ILabelSummary labelSummary) throws ConnectionException, RequestException, AccessException
Given an ILabelSummary object, construct a new Label object from it. This implementation simply gets the label on the Perforce server with the same name as the labelSummary's name by using the Label.refresh() object.If labelSummary is null this is equivalent to calling the default constructor; otherwise all LabelSummary fields are copied, and if labelSummary.getName() is not null, the refresh() is performed.
- Parameters:
labelSummary
- possibly-null ILabelSummary object.- Throws:
ConnectionException
- on errorRequestException
- on errorAccessException
- on error
-
-
Method Detail
-
newLabel
public static Label newLabel(IServer server, java.lang.String name, java.lang.String description, java.lang.String[] mapping)
Create a new local Label object with the given name, description, and view mapping. The new object is local only (i.e. it does not exist as a "real" Perforce label on the server) and is not locked, has no revision spec, and has its owner name field set to the current user. Other defaults are as given for the Label and LabelSummary default constructors.- Parameters:
server
- non-null server to be associated with this label.name
- non-null label name.description
- if not null, the new label's description field; if null, Label.DEFAULT_DESCRIPTION is used instead.mapping
- if not null, defines the left hand sides of the label's view map; if null, defaults to a single mapping as defined in Label.DEFAULT_MAPPING.- Returns:
- new local Label object.
-
refresh
public void refresh() throws ConnectionException, RequestException, AccessException
This method will refresh by getting the complete label model. If this refresh is successful then this label will be marked as complete.- Specified by:
refresh
in interfaceIServerResource
- Overrides:
refresh
in classServerResource
- Throws:
ConnectionException
- if the Perforce server is unreachable or is not connected.RequestException
- if the Perforce server encounters an error during its processing of the requestAccessException
- if the Perforce server denies access to the caller- See Also:
ServerResource.refresh()
-
updateOnServer
@Deprecated public java.lang.String updateOnServer() throws ConnectionException, RequestException, AccessException
Deprecated.use update() instead.Description copied from interface:ILabel
Update (or even create) this label on the associated Perforce server, if that server has been set for this label. Will throw a suitable RequestException if the label is not associated with a server, either as the result of being returned from a server earlier, or as the result of an explicit call on the underlying implementation object.Note that you should only call this method on "full" labels, i.e. those returned from an explicit single call to IServer.getLabel() or those created by hand; calling this on a label returned from the getLabelList() method may cause the associated in-server label to lose its view mapping.
- Specified by:
updateOnServer
in interfaceILabel
- Returns:
- the string message resulting from the update
- Throws:
ConnectionException
- if the Perforce server is unreachable or is not connected.RequestException
- if the Perforce server encounters an error during its processing of the requestAccessException
- if the Perforce server denies access to the caller- See Also:
ILabel.updateOnServer()
-
update
public void update() throws ConnectionException, RequestException, AccessException
Description copied from interface:IServerResource
Update the Perforce server object associated with the underlying P4Java object, if possible. The semantics of server updates are generally object-specific and will be spelled out for each participating object.The results of calling this method on objects whose canUpdate method returns false are undefined (but will generally result in a UnimplementedError being thrown).
- Specified by:
update
in interfaceILabel
- Specified by:
update
in interfaceIServerResource
- Overrides:
update
in classServerResource
- Throws:
ConnectionException
- if the Perforce server is unreachable or is not connected.RequestException
- if the Perforce server encounters an error during its processing of the requestAccessException
- if the Perforce server denies access to the caller- See Also:
ServerResource.update()
-
setViewMapping
public void setViewMapping(ViewMap<ILabelMapping> viewMapping)
Description copied from interface:ILabel
Set the view mapping for this label. Note that only the left hand side (the depot path) of a mapping is used for labels and will be valid here.- Specified by:
setViewMapping
in interfaceILabel
- Parameters:
viewMapping
- list of IClientViewMapping mappings for this label.- See Also:
ILabel.setViewMapping(com.perforce.p4java.core.ViewMap)
-
getViewMapping
public ViewMap<ILabelMapping> getViewMapping()
Description copied from interface:ILabel
Get the view mapping for this label. Note that only the left hand side (the depot path) of a mapping is used for labels and will be valid here.Note also that this method will only return the actual view mapping a label if the label object was returned from the IServer's getLabel() method (this is due to limitations in the underlying implementation).
- Specified by:
getViewMapping
in interfaceILabel
- Returns:
- non-null but possibly empty list of IClientViewMapping mappings for this label.
- See Also:
ILabel.getViewMapping()
-
getServer
public IServer getServer()
Description copied from interface:ILabel
Get the Perforce server object associated with this label.- Specified by:
getServer
in interfaceILabel
- Returns:
- possibly-null IServer object associated with this label.
- See Also:
ILabel.getServer()
-
setServer
public void setServer(IServer server)
Description copied from interface:IServerResource
Set the server associated with this resource. Setting this null can have bad effects down the line...- Specified by:
setServer
in interfaceILabel
- Specified by:
setServer
in interfaceIServerResource
- Overrides:
setServer
in classServerResource
- Parameters:
server
- IServer to be used for refresh, update, etc.- See Also:
ILabel.setServer(com.perforce.p4java.server.IServer)
-
-