JhlInfo2.java.svn-base
Upload User: liminzq
Upload Date: 2017-11-13
Package Size: 15143k
Code Size: 6k
Category:

Jsp/Servlet

Development Platform:

Java

  1. /*******************************************************************************
  2.  * Copyright (c) 2004, 2006 svnClientAdapter project and others.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *     http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  * Contributors:
  17.  *     svnClientAdapter project committers - initial API and implementation
  18.  ******************************************************************************/
  19. package org.tigris.subversion.svnclientadapter.javahl;
  20. import java.io.File;
  21. import java.io.IOException;
  22. import java.net.MalformedURLException;
  23. import java.util.Date;
  24. import org.tigris.subversion.javahl.Depth;
  25. import org.tigris.subversion.javahl.Info2;
  26. import org.tigris.subversion.svnclientadapter.ISVNInfo;
  27. import org.tigris.subversion.svnclientadapter.SVNNodeKind;
  28. import org.tigris.subversion.svnclientadapter.SVNScheduleKind;
  29. import org.tigris.subversion.svnclientadapter.SVNUrl;
  30. import org.tigris.subversion.svnclientadapter.SVNRevision.Number;
  31. /**
  32.  * A JavaHL based implementation of {@link ISVNInfo}.
  33.  * Actually just an adapter from {@link org.tigris.subversion.javahl.Info2}
  34.  *  
  35.  * @author C閐ric Chabanois
  36.  */
  37. public class JhlInfo2 implements ISVNInfo {
  38. private Info2 info;
  39. private File file;
  40. /**
  41.  * Constructor
  42.  * @param file
  43.  * @param info
  44.  */
  45. public JhlInfo2(File file, Info2 info) {
  46.         super();
  47.         this.file = file;
  48.         this.info = info;
  49. }
  50. /* (non-Javadoc)
  51.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getFile()
  52.  */
  53. public File getFile() {
  54. if (file == null) return null;
  55. try {
  56. return file.getCanonicalFile();
  57. } catch (IOException e) {
  58. return null;
  59. }
  60. }
  61. /* (non-Javadoc)
  62.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrl()
  63.  */
  64. public SVNUrl getUrl() {
  65. try {
  66. return new SVNUrl(info.getUrl());
  67. } catch (MalformedURLException e) {
  68.             //should never happen.
  69. return null;
  70. }
  71. }
  72. /* (non-Javadoc)
  73.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrlString()
  74.  */
  75. public String getUrlString() {
  76. return info.getUrl();
  77. }
  78. /* (non-Javadoc)
  79.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUuid()
  80.  */
  81. public String getUuid() {
  82. return info.getReposUUID();
  83. }
  84. /* (non-Javadoc)
  85.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRepository()
  86.  */
  87. public SVNUrl getRepository() {
  88. try {
  89. return new SVNUrl(info.getReposRootUrl());
  90. } catch (MalformedURLException e) {
  91.             //should never happen.
  92. return null;
  93. }
  94. }
  95. /* (non-Javadoc)
  96.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getSchedule()
  97.  */
  98. public SVNScheduleKind getSchedule() {
  99. return JhlConverter.convertScheduleKind(info.getSchedule());
  100. }
  101. /* (non-Javadoc)
  102.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getNodeKind()
  103.  */
  104. public SVNNodeKind getNodeKind() {
  105. return JhlConverter.convertNodeKind(info.getKind());
  106. }
  107. /* (non-Javadoc)
  108.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getAuthor()
  109.  */
  110. public String getLastCommitAuthor() {
  111. return info.getLastChangedAuthor();
  112. }
  113. /* (non-Javadoc)
  114.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRevision()
  115.  */
  116. public Number getRevision() {
  117. return JhlConverter.convertRevisionNumber(info.getRev());
  118. }
  119. /* (non-Javadoc)
  120.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedRevision()
  121.  */
  122. public Number getLastChangedRevision() {
  123. return JhlConverter.convertRevisionNumber(info.getLastChangedRev());
  124. }
  125. /* (non-Javadoc)
  126.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedDate()
  127.  */
  128. public Date getLastChangedDate() {
  129. return info.getLastChangedDate();
  130. }
  131. /* (non-Javadoc)
  132.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDateTextUpdate()
  133.  */
  134. public Date getLastDateTextUpdate() {
  135. return info.getTextTime();
  136. }
  137. /* (non-Javadoc)
  138.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDatePropsUpdate()
  139.  */
  140. public Date getLastDatePropsUpdate() {
  141. return info.getPropTime();
  142. }
  143. /* (non-Javadoc)
  144.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#isCopied()
  145.  */
  146. public boolean isCopied() {
  147. return (info.getCopyFromRev() > 0);
  148. }
  149. /* (non-Javadoc)
  150.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyRev()
  151.  */
  152. public Number getCopyRev() {
  153. return JhlConverter.convertRevisionNumber(info.getCopyFromRev());
  154. }
  155. /* (non-Javadoc)
  156.  * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyUrl()
  157.  */
  158. public SVNUrl getCopyUrl() {
  159. try {
  160. return new SVNUrl(info.getCopyFromUrl());
  161. } catch (MalformedURLException e) {
  162.             //should never happen.
  163. return null;
  164. }
  165. }
  166.     /* (non-Javadoc)
  167.      * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockCreationDate()
  168.      */
  169.     public Date getLockCreationDate() {
  170.      if (info.getLock() == null)
  171.      return null;
  172.      else
  173.      return info.getLock().getCreationDate();
  174.     }
  175.     /* (non-Javadoc)
  176.      * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockOwner()
  177.      */
  178.     public String getLockOwner() {
  179.      if (info.getLock() == null)
  180.      return null;
  181.      else
  182.      return info.getLock().getOwner();
  183.     }
  184.     /* (non-Javadoc)
  185.      * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockComment()
  186.      */
  187.     public String getLockComment() {
  188.      if (info.getLock() == null)
  189.      return null;
  190.      else
  191.      return info.getLock().getComment();
  192.     }
  193.     
  194.     /* (non-Javadoc)
  195.      * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getDepth()
  196.      */
  197.     public int getDepth() {
  198.      return info.getDepth();
  199.     }    
  200. }