FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.utils.RDPFileParser Class Reference

Public Member Functions

void parse (Reader reader) throws IOException
 
String getString (String optionName)
 
Integer getInteger (String optionName)
 

Detailed Description

Definition at line 19 of file RDPFileParser.java.

Constructor & Destructor Documentation

◆ RDPFileParser()

com.freerdp.freerdpcore.utils.RDPFileParser.RDPFileParser ( )
inline

Definition at line 27 of file RDPFileParser.java.

28 {
29 options = new HashMap<>();
30 }

Member Function Documentation

◆ getInteger()

Integer com.freerdp.freerdpcore.utils.RDPFileParser.getInteger ( String  optionName)
inline

Definition at line 93 of file RDPFileParser.java.

94 {
95 if (options.get(optionName) instanceof Integer)
96 return (Integer)options.get(optionName);
97 else
98 return null;
99 }

◆ getString()

String com.freerdp.freerdpcore.utils.RDPFileParser.getString ( String  optionName)
inline

Definition at line 85 of file RDPFileParser.java.

86 {
87 if (options.get(optionName) instanceof String)
88 return (String)options.get(optionName);
89 else
90 return null;
91 }

◆ parse()

void com.freerdp.freerdpcore.utils.RDPFileParser.parse ( Reader  reader) throws IOException
inline

Definition at line 32 of file RDPFileParser.java.

33 {
34 BufferedReader br = new BufferedReader(reader);
35 String line = null;
36
37 int errors = 0;
38 int lines = 0;
39 boolean ok;
40
41 while ((line = br.readLine()) != null)
42 {
43 lines++;
44 ok = false;
45
46 if (errors > MAX_ERRORS || lines > MAX_LINES)
47 {
48 br.close();
49 throw new IOException("Parsing limits exceeded");
50 }
51
52 String[] fields = line.split(":", 3);
53
54 if (fields.length == 3)
55 {
56 if (fields[1].equals("s"))
57 {
58 options.put(fields[0].toLowerCase(Locale.ENGLISH), fields[2]);
59 ok = true;
60 }
61 else if (fields[1].equals("i"))
62 {
63 try
64 {
65 Integer i = Integer.parseInt(fields[2]);
66 options.put(fields[0].toLowerCase(Locale.ENGLISH), i);
67 ok = true;
68 }
69 catch (NumberFormatException e)
70 {
71 }
72 }
73 else if (fields[1].equals("b"))
74 {
75 ok = true;
76 }
77 }
78
79 if (!ok)
80 errors++;
81 }
82 br.close();
83 }

The documentation for this class was generated from the following file: