| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| StatusLine |
|
| 2.3333333333333335;2.333 | ||||
| StatusLine$Type |
|
| 2.3333333333333335;2.333 |
| 1 | /* | |
| 2 | * #%L | |
| 3 | * JavaHg | |
| 4 | * %% | |
| 5 | * Copyright (C) 2011 aragost Trifork ag | |
| 6 | * %% | |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 8 | * of this software and associated documentation files (the "Software"), to deal | |
| 9 | * in the Software without restriction, including without limitation the rights | |
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 11 | * copies of the Software, and to permit persons to whom the Software is | |
| 12 | * furnished to do so, subject to the following conditions: | |
| 13 | * | |
| 14 | * The above copyright notice and this permission notice shall be included in | |
| 15 | * all copies or substantial portions of the Software. | |
| 16 | * | |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 23 | * THE SOFTWARE. | |
| 24 | * #L% | |
| 25 | */ | |
| 26 | package com.aragost.javahg.commands; | |
| 27 | ||
| 28 | import java.io.IOException; | |
| 29 | ||
| 30 | import com.aragost.javahg.internals.BaseStatusLine; | |
| 31 | import com.aragost.javahg.internals.HgInputStream; | |
| 32 | ||
| 33 | /** | |
| 34 | * A parsed line from the <tt>hg status</tt> output. | |
| 35 | */ | |
| 36 | 54 | public class StatusLine extends BaseStatusLine<StatusLine.Type> { |
| 37 | ||
| 38 | /** | |
| 39 | * Status line types. | |
| 40 | */ | |
| 41 | 27 | public enum Type { |
| 42 | ||
| 43 | /** | |
| 44 | * A modified file. | |
| 45 | */ | |
| 46 | 1 | MODIFIED('M'), |
| 47 | /** | |
| 48 | * An added file. | |
| 49 | */ | |
| 50 | 1 | ADDED('A'), |
| 51 | /** | |
| 52 | * A removed file. | |
| 53 | */ | |
| 54 | 1 | REMOVED('R'), |
| 55 | /** | |
| 56 | * A clean file. | |
| 57 | */ | |
| 58 | 1 | CLEAN('C'), |
| 59 | /** | |
| 60 | * A missing file (deleted outside of Mercurial) | |
| 61 | */ | |
| 62 | 1 | MISSING('!'), |
| 63 | /** | |
| 64 | * An unknown file. | |
| 65 | */ | |
| 66 | 1 | UNKNOWN('?'), |
| 67 | /** | |
| 68 | * An ignored file. | |
| 69 | */ | |
| 70 | 1 | IGNORED('I'), |
| 71 | /** | |
| 72 | * The origin of a copied file. | |
| 73 | */ | |
| 74 | 1 | ORIGIN(' '); |
| 75 | ||
| 76 | private final char discriminator; | |
| 77 | ||
| 78 | 8 | private Type(char discriminator) { |
| 79 | 8 | this.discriminator = discriminator; |
| 80 | 8 | } |
| 81 | } | |
| 82 | ||
| 83 | /** | |
| 84 | * @param stream | |
| 85 | * the output of <tt>hg status</tt> | |
| 86 | * @return the parsed status line | |
| 87 | * @throws IOException | |
| 88 | */ | |
| 89 | public static StatusLine fromStream(HgInputStream stream) throws IOException { | |
| 90 | 27 | StatusLine result = new StatusLine(); |
| 91 | 27 | result.initFromStream(stream); |
| 92 | 27 | return result; |
| 93 | } | |
| 94 | ||
| 95 | @Override | |
| 96 | protected Type typeForChar(char ch) { | |
| 97 | 93 | for (Type t : Type.values()) { |
| 98 | 93 | if (t.discriminator == ch) { |
| 99 | 27 | return t; |
| 100 | } | |
| 101 | } | |
| 102 | 0 | throw new IllegalArgumentException("No status type for " + ch); |
| 103 | } | |
| 104 | } |