1 package org.apache.maven.wagon.providers.ssh;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.BufferedReader;
23 import java.io.IOException;
24 import java.io.StringReader;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.regex.Matcher;
28 import java.util.regex.Pattern;
29
30 import org.apache.maven.wagon.TransferFailedException;
31
32
33
34
35
36
37
38 public class LSParser
39 {
40 private final static Pattern PATTERN = Pattern.compile( ".+\\s+[0-9]+\\s+.+\\s+.+\\s+[0-9]+\\s+"
41 + "([0-9]{4}-[0-9]{2}-[0-9]{2}|.+\\s+[0-9]+)\\s+[0-9:]+\\s+(.+?)" );
42
43
44
45
46
47
48
49
50
51
52 public List parseFiles( String rawLS )
53 throws TransferFailedException
54 {
55 List ret = new ArrayList();
56 try
57 {
58 BufferedReader br = new BufferedReader( new StringReader( rawLS ) );
59
60 String line = br.readLine();
61
62 while ( line != null )
63 {
64 line = line.trim();
65
66 Matcher m = PATTERN.matcher( line );
67 if ( m.matches() )
68 {
69 ret.add( m.group( 2 ) );
70 }
71 line = br.readLine();
72 }
73 }
74 catch ( IOException e )
75 {
76 throw new TransferFailedException( "Error parsing file listing.", e );
77 }
78
79 return ret;
80 }
81 }