/*****************************************************************************
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License Version
* 1.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is available at http://www.sun.com/
*
* The Original Code is the CVS Client Library.
* The Initial Developer of the Original Code is Robert Greig.
* Portions created by Robert Greig are Copyright (C) 2000.
* All Rights Reserved.
*
* Contributor(s): Robert Greig.
*****************************************************************************/
package org.netbeans.lib.cvsclient.admin;
import java.text.*;
import java.util.*;
import org.netbeans.lib.cvsclient.util.*;
/**
* The class abstracts the CVS concept of an <i>entry line</i>. The entry
* line is textually of the form:<p>
* / name / version / conflict / options / tag_or_date
* <p>These are explained in section 5.1 of the CVS protocol 1.10 document.
*
* @author Robert Greig
*/
public final class Entry {
// Constants ==============================================================
private static final ILogger LOG = LoggerManager.getLogger("javacvs.entry");
private static final String DUMMY_TIMESTAMP = "dummy timestamp";
private static final String DUMMY_TIMESTAMP_NEW_ENTRY = "dummy timestamp from new-entry";
private static final String MERGE_TIMESTAMP = "Result of merge";
private static final String STICKY_TAG_REVISION_PREFIX = "T";
private static final String STICKY_DATE_PREFIX = "D";
private static final String BINARY_FILE = "-kb";
private static final String HAD_CONFLICTS = "+";
private static final char TIMESTAMP_MATCHES_FILE = '=';
private static final String REVISION_ADDED = "0";
private static final String REVISION_REMOVED_PREFIX = "-";
private static final SimpleDateFormat STICKY_DATE_FORMAT = new SimpleDateFormat("yyyy.MM.dd.hh.mm.ss");
// Static =================================================================
private static SimpleDateFormat lastModifiedDateFormatter;
public static synchronized String formatLastModifiedDate(Date date) {
return getLastModifiedDateFormatter().format(date);
}
public static Entry createDirectoryEntry(String directoryName) {
final Entry entry = new Entry();
entry.setFileName(directoryName);
entry.setDirectory(true);
return entry;
}
public static Entry createFileEntry(String fileName) {
final Entry entry = new Entry();
entry.setFileName(fileName);
entry.setDirectory(false);
return entry;
}
public static Entry createEntryForLine(String entryLine) {
final Entry entry = new Entry();
entry.parseLine(entryLine);
return entry;
}
// Fields =================================================================
private boolean directory;
private String fileName;
private Date lastModified;
private String revision;
private boolean conflict;
private boolean timeStampMatchesFile;
private String conflictString;
private String conflictStringWithoutConflictMarker;
private String options;
private String stickyRevision;
private String stickyTag;
private String stickyDateString;
private Date stickyDate;
// Setup ==================================================================
private Entry() {
}
// Implemented ============================================================
public String toString() {
final StringBuffer buffer = new StringBuffer();
if (directory) {
buffer.append("D/");
}
else {
buffer.append('/');
}
// if name is null, then this is a totally empty entry, so append
// nothing further
if (fileName != null) {
buffer.append(fileName);
buffer.append('/');
if (revision != null) {
buffer.append(revision);
}
buffer.append('/');
if (conflictString != null) {
buffer.append(conflictString);
}
buffer.append('/');
if (options != null) {
buffer.append(options);
}
buffer.append('/');
if (stickyTag != null) {
buffer.append(STICKY_TAG_REVISION_PREFIX);
buffer.append(stickyTag);
}
else if (stickyRevision != null) {
buffer.append(STICKY_TAG_REVISION_PREFIX);
buffer.append(stickyRevision);
}
else if (stickyDateString != null) {
buffer.append(STICKY_DATE_PREFIX);
buffer.append(stickyDateString);
}
}
return buffer.toString();
}
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
return false;
}
final String entryFileName = ((Entry)obj).fileName;
return (fileName == entryFileName)
|| (fileName != null && fileName.equals(entryFileName));
}
public int hashCode() {
return (fileName != null)
? fileName.hashCode()
: 0;
}
// Accessing ==============================================================
public String getFileName() {
return fileName;
}
public String getRevision() {
return revision;
}
public void setRevision(String revision) {
this.revision = revision;
}
public Date getLastModified() {
return lastModified;
}
public boolean isResultOfMerge() {
return conflictString != null && conflictString.startsWith(MERGE_TIMESTAMP);
}
public void setConflict(String conflictString) {
this.conflictString = conflictString;
}
public String getOptions() {
return options;
}
public String getStickyTag() {
return stickyTag;
}
public void setStickyTag(String stickyTag) {
this.stickyTag = stickyTag;
this.stickyRevision = null;
this.stickyDateString = null;
this.stickyDate = null;
}
public String getStickyRevision() {
return stickyRevision;
}
public void setStickyRevision(String stickyRevision) {
this.stickyTag = null;
this.stickyRevision = stickyRevision;
this.stickyDateString = null;
this.stickyDate = null;
}
public String getStickyDateString() {
return stickyDateString;
}
public void setStickyDateString(String stickyDateString) {
this.stickyTag = null;
this.stickyRevision = null;
this.stickyDateString = stickyDateString;
this.stickyDate = null;
}
public Date getStickyDate() {
// lazy generation
if (stickyDate != null) {
return stickyDate;
}
if (stickyDateString == null) {
return null;
}
try {
return STICKY_DATE_FORMAT.parse(stickyDateString);
}
catch (ParseException ex) {
// ignore silently
return null;
}
}
public void setStickyDate(Date stickyDate) {
if (stickyDate == null) {
this.stickyTag = null;
this.stickyRevision = null;
this.stickyDateString = null;
this.stickyDate = null;
return;
}
this.stickyTag = null;
this.stickyRevision = null;
this.stickyDateString = STICKY_DATE_FORMAT.format(stickyDate);
this.stickyDate = stickyDate;
}
public String getStickyOption() {
if (stickyTag != null) {
return stickyTag;
}
if (stickyRevision != null) {
return stickyRevision;
}
return stickyDateString;
}
public void setStickyInformation(Entry entry) {
stickyTag = entry.stickyTag;
stickyRevision = entry.stickyRevision;
stickyDateString = entry.stickyDateString;
stickyDate = entry.stickyDate;
}
public void setStickyInformation(String stickyInformation) {
if (stickyInformation == null) {
resetStickyInformation();
return;
}
if (stickyInformation.startsWith(STICKY_TAG_REVISION_PREFIX)) {
final String tagOrRevision = stickyInformation.substring(STICKY_TAG_REVISION_PREFIX.length());
if (tagOrRevision.length() == 0) {
resetStickyInformation();
return;
}
final char firstChar = tagOrRevision.charAt(0);
if (firstChar >= '0' && firstChar <= '9') {
setStickyRevision(tagOrRevision);
}
else {
setStickyTag(tagOrRevision);
}
return;
}
if (stic
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
NetBeans CVS source (160个子文件)
Entry.java 14KB
RequestProcessor.java 12KB
DefaultResponseHandler.java 12KB
ResponseParser.java 10KB
PServerPasswordScrambler.java 8KB
Requests.java 7KB
FileSystemScanner.java 7KB
FileUtils.java 7KB
EventManager.java 6KB
FilePermissions.java 5KB
ConnectionStreams.java 5KB
SimpleStringPattern.java 5KB
EditCommand.java 5KB
AbstractRequestFactory.java 5KB
EditorsMessageParser.java 5KB
FileStatus.java 4KB
RepositoryFileNameParser.java 4KB
ResponseProgressHandler.java 4KB
DirectoryPruner.java 4KB
ValidRequestsResponseHandler.java 4KB
FsPathUtils.java 4KB
UneditCommand.java 3KB
WatchCommand.java 3KB
EditorsCommand.java 3KB
RemoveRequestFactory.java 3KB
WatchMode.java 3KB
WatchersCommand.java 3KB
EditRequestFactory.java 3KB
CommandRequest.java 3KB
FsPath.java 3KB
Utf8InputStreamReader.java 3KB
CvsFile.java 3KB
GlobalOptions.java 3KB
AbstractCommand.java 3KB
KeywordSubstitution.java 2KB
FileInfoAndMessageResponseProgressHandler.java 2KB
CvsFiles.java 2KB
AbstractInputStreamReader.java 2KB
IResponseHandler.java 2KB
ModifiedRequest.java 2KB
NotifyRequest.java 2KB
Watch.java 2KB
WatchRequestFactory.java 2KB
UneditRequestFactory.java 2KB
CommandUtils.java 2KB
EntryRequest.java 2KB
AbstractOutputStreamWriter.java 2KB
EditorsFileInfoContainer.java 2KB
AbstractMessageParser.java 2KB
FileStateRequestsProgressHandler.java 2KB
DirectoryRequest.java 2KB
DefaultEntryParser.java 2KB
IConnection.java 2KB
ILocalFileWriter.java 2KB
EditorsRequestFactory.java 2KB
FileInfoAndDirectoryResponseProgressHandler.java 2KB
WatchersRequestFactory.java 2KB
FsDirectoryPath.java 2KB
IAdminWriter.java 2KB
TaggedMessageParser.java 2KB
EditEditorsMessageParser.java 2KB
SolveableAuthenticationException.java 2KB
RangeProgressViewer.java 2KB
ArgumentRequest.java 2KB
DefaultFileInfo.java 2KB
FsFilePath.java 2KB
ArgumentxRequest.java 2KB
ValidResponsesRequest.java 1KB
LocalFileStatus.java 1KB
GlobalOptionRequest.java 1KB
FileDetails.java 1KB
RootRequest.java 1KB
Utf8OutputStreamWriter.java 1KB
LocalDirectoryRequest.java 1KB
IRequest.java 1KB
LocalFiles.java 1KB
IAdminReader.java 1KB
AuthenticationException.java 1KB
UnchangedRequest.java 1KB
ExpandModulesRequest.java 1KB
DualListener.java 1KB
QuestionableRequest.java 1KB
ResponseExpectingRequest.java 1KB
BugLog.java 1KB
ICvsListenerRegistry.java 1KB
IRequestProcessor.java 1KB
ILocalFileReader.java 1KB
RemoveParser.java 1KB
AbstractParser.java 1KB
ICvsFileSystem.java 1KB
StreamUtilities.java 1KB
UseUnchangedRequest.java 1KB
AsciiOutputStreamWriter.java 1KB
ISendTextFilePreprocessor.java 1KB
IsModifiedRequest.java 1KB
CommandException.java 1KB
CaseRequest.java 1KB
IClientEnvironment.java 1KB
TabStringTokenizer.java 1KB
StickyRequest.java 1KB
共 160 条
- 1
- 2
资源评论
- y_xzh2013-08-26资源没太看懂,先收着,回头再仔细研究一下
garlicgao
- 粉丝: 4
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功