/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
*/
package org.opensolaris.opengrok.history;
import java.io.Serializable;
/**
* Class to contain the common info for a repository. This object
* will live on the server and the client side, so don't add logic
* that will only work on one side in this object.
*
* @author Trond Norbye
*/
public class RepositoryInfo implements Serializable {
private static final long serialVersionUID = 1L;
/** the directory name (canonical path incl. source root) of the repository
* currently processed */
protected String directoryName;
/** indicate, whether the related CLI command is working. {@code null} means
* not yet tested.
* @see RepoRepository#isWorking()
* @see RepoRepository#ensureCommand(String, String)
*/
protected Boolean working;
/** the type of the repository. Usually a very short constant name. */
protected String type;
/** indicate, whether history info for this repository is stored remotely */
protected boolean remote;
/** pattern used to parse dates from logs, command output */
protected String datePattern;
/**
* Empty constructor to support serialization.
*/
public RepositoryInfo() {
super();
}
/**
* Create a copy of the given repo info.
* @param orig info to copy.
* @throws NullPointerException if the parameter is {@code null}
*/
public RepositoryInfo(RepositoryInfo orig) {
setDirectoryName(orig.directoryName);
this.type = orig.type;
this.working = Boolean.valueOf(orig.isWorking());
this.remote = orig.isRemote();
this.datePattern = orig.datePattern;
}
/**
* Get the name of the root directory for this repository.
* @return the name of the root directory (canonical path incl. source root).
*/
public String getDirectoryName() {
return directoryName;
}
/**
* Specify the name of the root directory for this repository.
* @param directoryName the new name of the root directory (canonical path
* incl. source root).
*/
public void setDirectoryName(String directoryName) {
this.directoryName = directoryName;
}
/**
* Returns true if this repository is usable in this context (for SCM
* systems that use external binaries, the binary must be availabe etc)
*
* @return true if the HistoryGuru may use the repository
*/
public boolean isWorking() {
return working != null && working.booleanValue();
}
/**
* Set the property working
*
* @param working
*/
public void setWorking(Boolean working) {
this.working = working;
}
/**
* Is the history and version information for this repository stored on
* a remote server?
*
* @return true if the history is stored on a remote server.
*/
public boolean isRemote() {
return remote;
}
/**
* Set the property remote
* @param remote
*/
public void setRemote(boolean remote) {
this.remote = remote;
}
/**
* get property type
* @return type
*/
public String getType() {
return type;
}
/**
* Set property type
* @param type
*/
public void setType(String type) {
this.type = type;
}
/**
* Set the pattern to use for parsing dates in command output, logs, etc.
* @param datePattern pattern to set.
*/
public void setDatePattern(String datePattern) {
this.datePattern = datePattern;
}
/**
* Get the pattern to use for parsing dates in command output, logs, etc.
* @return the pattern currently set, which should not but could be {@code null}.
*/
public String getDatePattern() {
return datePattern;
}
}