Base layout of eclipse plugin for service provider.
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ServiceProviderPlugin / src / oic / simulator / serviceprovider / utils / Convertion.java
1 package oic.simulator.serviceprovider.utils;
2
3 public class Convertion {
4
5     public static String uriToDisplayName(String uri) {
6         String result = null;
7         if (null != uri) {
8             String tokens[] = uri.split(Constants.FORWARD_SLASH);
9             System.out.println(uri);
10             System.out.println(tokens.length);
11             if (Constants.PROPER_RESOURCE_URI_TOKEN_COUNT == tokens.length) {
12                 // Proper URI
13                 result = tokens[2] + Constants.UNDERSCORE + tokens[4];
14             }
15         }
16         return result;
17     }
18
19     public static String displayNameToUri(String displayName) {
20         String result = null;
21         if (null != displayName) {
22             String tokens[] = displayName.split(Constants.UNDERSCORE);
23             if (2 == tokens.length) {
24                 // Proper Display Name
25                 result = Constants.FORWARD_SLASH + Constants.OIC
26                         + Constants.FORWARD_SLASH + tokens[0]
27                         + Constants.FORWARD_SLASH + Constants.SIMULATOR
28                         + Constants.FORWARD_SLASH + tokens[1];
29             }
30         }
31         return result;
32     }
33
34     public static boolean isUriComplete(String uri) {
35         boolean uriComplete = false;
36         if (null != uri) {
37             String tokens[] = uri.split(Constants.FORWARD_SLASH);
38             System.out.println(uri);
39             System.out.println(tokens.length);
40             if (Constants.PROPER_RESOURCE_URI_TOKEN_COUNT == tokens.length) {
41                 uriComplete = true;
42             }
43         }
44         return uriComplete;
45     }
46 }