All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.tmatesoft.svn.core.SVNNodeKind Maven / Gradle / Ivy

Go to download

The only pure Java Subversion library in the world, formerly known as JavaSVN

The newest version!
/*
 * ====================================================================
 * Copyright (c) 2004-2006 TMate Software Ltd.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://svnkit.com/license.html
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */

package org.tmatesoft.svn.core;


/**
 * The SVNNodeKind class is used to describe the kind of a 
 * directory entry (node, in other words). This can be:
 * 
    *
  • a directory - the node is a directory *
  • a file - the node is a file *
  • none - the node is missing (does not exist) *
  • unknown - the node kind can not be recognized *
* * @version 1.1.0 * @author TMate Software Ltd. * @see SVNDirEntry */ public final class SVNNodeKind implements Comparable { /** * This node kind is used to say that a node is missing */ public static final SVNNodeKind NONE = new SVNNodeKind(2); /** * Defines the file node kind */ public static final SVNNodeKind FILE = new SVNNodeKind(1); /** * Defines the directory node kind */ public static final SVNNodeKind DIR = new SVNNodeKind(0); /** * This node kind is used to say that the kind of a node is * actually unknown */ public static final SVNNodeKind UNKNOWN = new SVNNodeKind(3); private int myID; private SVNNodeKind(int id) { myID = id; } /** * Parses the passed string and finds out the node kind. For instance, * parseKind("dir") will return * {@link #DIR}. * * @param kind a node kind as a string * @return an SVNNodeKind representation */ public static SVNNodeKind parseKind(String kind) { if ("file".equals(kind)) { return FILE; } else if ("dir".equals(kind)) { return DIR; } else if ("none".equals(kind) || kind == null) { return NONE; } return UNKNOWN; } /** * Represents the current SVNNodeKind object as a string. * * @return a string representation of this object. */ public String toString() { if (this == NONE) { return "none"; } else if (this == FILE) { return "file"; } else if (this == DIR) { return "dir"; } return "unknown"; } /** * Compares this object with another one. * Each SVNNodeKind constant has got its own unique id. * * @param o an object to compare with * @return
    *
  • -1 - if o is either null, * or is not an instance of SVNNodeKind, or the id of * this object is smaller than the id of o; *
  • *
  • 1 - if the id of this object is bigger than the id of * o; *
  • *
  • 0 - if and only if o is the same constant * value as this one (has the same id) *
  • *
*/ public int compareTo(Object o) { if (o == null || o.getClass() != SVNNodeKind.class) { return -1; } int otherID = ((SVNNodeKind) o).myID; return myID > otherID ? 1 : myID < otherID ? -1 : 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy