CheckoutEntryImpl.java

  1. /*
  2.  * Copyright (C) 2011-2013, Robin Rosenberg <robin.rosenberg@dewire.com> and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */

  10. package org.eclipse.jgit.internal.storage.file;

  11. import org.eclipse.jgit.lib.CheckoutEntry;
  12. import org.eclipse.jgit.lib.ReflogEntry;

  13. /**
  14.  * Parsed information about a checkout.
  15.  */
  16. public class CheckoutEntryImpl implements CheckoutEntry {
  17.     static final String CHECKOUT_MOVING_FROM = "checkout: moving from "; //$NON-NLS-1$

  18.     private String from;

  19.     private String to;

  20.     CheckoutEntryImpl(ReflogEntry reflogEntry) {
  21.         String comment = reflogEntry.getComment();
  22.         int p1 = CHECKOUT_MOVING_FROM.length();
  23.         int p2 = comment.indexOf(" to ", p1); //$NON-NLS-1$
  24.         int p3 = comment.length();
  25.         from = comment.substring(p1,p2);
  26.         to = comment.substring(p2 + " to ".length(), p3); //$NON-NLS-1$
  27.     }

  28.     /** {@inheritDoc} */
  29.     @Override
  30.     public String getFromBranch() {
  31.         return from;
  32.     }

  33.     /** {@inheritDoc} */
  34.     @Override
  35.     public String getToBranch() {
  36.         return to;
  37.     }
  38. }