source: java/main/src/main/java/com/framsticks/params/Util.java @ 78

Last change on this file since 78 was 78, checked in by psniegowski, 11 years ago

Add f0 parsing and f0->Model transformation.

File size: 1.0 KB
Line 
1package com.framsticks.params;
2
3import java.util.ArrayList;
4import java.util.List;
5
6/**
7 * @author Piotr Sniegowski
8 */
9public abstract class Util {
10    public static String readSourceToString(SourceInterface source) {
11        StringBuilder result = new StringBuilder();
12        String line;
13        while ((line = source.readLine()) != null) {
14            result.append(line).append(" ");
15        }
16        source.close();
17        return result.toString();
18    }
19        public static List<Object> stripAccessInterface(List<AccessInterface> accesses) {
20                List<Object> result = new ArrayList<Object>();
21                for (AccessInterface a : accesses) {
22                        result.add(a.getSelected());
23                }
24                return result;
25        }
26        public static int copyParams(AccessInterface to, AccessInterface from) {
27                int copied = 0;
28                for (Param f : from.getParams()) {
29                        Param t = from.getParam(f.getId());
30                        if (t == null) {
31                                continue;
32                        }
33                        if (to.getClass() != f.getClass()) {
34                                continue;
35                        }
36                        to.set(t, from.get(f, Object.class));
37                        ++copied;
38                }
39                return copied;
40        }
41}
Note: See TracBrowser for help on using the repository browser.