RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
LocalClasspathProcessor.java
1/*
2 * Copyright (c) 2013 Creative Sphere Limited.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing,
9 * software distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 *
14 * Contributors:
15 *
16 * Creative Sphere - initial API and implementation
17 *
18 */
19package org.ah.java.remotevmlauncher.protocol;
20
21import java.io.DataInputStream;
22import java.io.DataOutputStream;
23import java.io.IOException;
24import java.util.LinkedHashMap;
25import java.util.Map;
26
32public class LocalClasspathProcessor extends AbstractProcessor {
33
34 public static final String ID = "LC";
35
36 // pathId -> localClasspath
37 private Map<String, String> localClasspath = new LinkedHashMap<String, String>();
38
39 public LocalClasspathProcessor() {
40 super(ID);
41 }
42
43 public Map<String, String> getLocalClasspath() {
44 return localClasspath;
45 }
46
47 public void receive(DataInputStream dis) throws IOException {
48 localClasspath.clear();
49 int size = dis.readShort();
50 for (int i = 0; i < size; i++) {
51 String pathId = dis.readUTF();
52 String classpath = dis.readUTF();
53 localClasspath.put(pathId, classpath);
54 }
55 }
56
57 public void send(DataOutputStream dos) throws IOException {
58 dos.writeUTF(ID);
59 dos.writeShort(localClasspath.size());
60 for (Map.Entry<String, String> entry : localClasspath.entrySet()) {
61 dos.writeUTF(entry.getKey());
62 dos.writeUTF(entry.getValue());
63 }
64 dos.flush();
65 }
66}
67