View Javadoc
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  
11  package org.eclipse.jgit.internal.storage.file;
12  
13  import org.eclipse.jgit.lib.CheckoutEntry;
14  import org.eclipse.jgit.lib.ReflogEntry;
15  
16  /**
17   * Parsed information about a checkout.
18   */
19  public class CheckoutEntryImpl implements CheckoutEntry {
20  	static final String CHECKOUT_MOVING_FROM = "checkout: moving from "; //$NON-NLS-1$
21  
22  	private String from;
23  
24  	private String to;
25  
26  	CheckoutEntryImpl(ReflogEntry reflogEntry) {
27  		String comment = reflogEntry.getComment();
28  		int p1 = CHECKOUT_MOVING_FROM.length();
29  		int p2 = comment.indexOf(" to ", p1); //$NON-NLS-1$
30  		int p3 = comment.length();
31  		from = comment.substring(p1,p2);
32  		to = comment.substring(p2 + " to ".length(), p3); //$NON-NLS-1$
33  	}
34  
35  	/** {@inheritDoc} */
36  	@Override
37  	public String getFromBranch() {
38  		return from;
39  	}
40  
41  	/** {@inheritDoc} */
42  	@Override
43  	public String getToBranch() {
44  		return to;
45  	}
46  }