blob: 92df8938f10c95b7f496ad5030f0eabdfe33c4ca [file] [log] [blame]
Akihiro Yamanouchid4912842016-07-01 10:38:46 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.drivers.fujitsu;
18
19/**
20 * Defines common XML constants and methods for Fujitsu vOLT.
21 */
22public final class FujitsuVoltXmlUtility {
23
24 public static final String COLON = ":";
25 public static final String HYPHEN = "-";
26 public static final String SLASH = "/";
27 public static final String SPACE = " ";
28 public static final String NEW_LINE = "\n";
29 public static final String ANGLE_LEFT = "<";
30 public static final String ANGLE_RIGHT = ">";
31
32 public static final String REPORT_ALL = "report-all";
33 public static final String EDIT_CONFIG = "edit-config";
34 public static final String RUNNING = "running";
35
36 public static final String VOLT_NE_NAMESPACE =
37 "xmlns=\"http://fujitsu.com/ns/volt/1.1\"";
38 public static final String VOLT_NE = "volt-ne";
39 public static final String PONLINK_ID = "ponlink-id";
40 public static final String ONU_ID = "onu-id";
41
42 public static final String VOLT_NE_OPEN = ANGLE_LEFT + VOLT_NE + SPACE;
43 public static final String VOLT_NE_CLOSE = ANGLE_LEFT + SLASH + VOLT_NE + ANGLE_RIGHT;
44
45 private FujitsuVoltXmlUtility() {
46 // Preventing any allocation
47 }
48
49 /**
50 * Builds XML start tag with name provided.
51 *
52 * @param name tag name
53 * @return string
54 */
55 public static String buildStartTag(String name) {
56 return buildStartTag(name, true);
57 }
58
59 /**
60 * Builds XML end tag with name provided.
61 *
62 * @param name tag name
63 * @return string
64 */
65 public static String buildEndTag(String name) {
66 return buildEndTag(name, true);
67 }
68
69 /**
70 * Builds XML empty tag with name provided.
71 *
72 * @param name tag name
73 * @return string
74 */
75 public static String buildEmptyTag(String name) {
76 return buildEmptyTag(name, true);
77 }
78
79 /**
80 * Builds XML start tag with name provided.
81 *
82 * @param name tag name
83 * @param addNewLine option to add new line character after tag
84 * @return string
85 */
86 public static String buildStartTag(String name, boolean addNewLine) {
87 if (addNewLine) {
88 return (ANGLE_LEFT + name + ANGLE_RIGHT + NEW_LINE);
89 } else {
90 return (ANGLE_LEFT + name + ANGLE_RIGHT);
91 }
92 }
93
94 /**
95 * Builds XML end tag with name provided.
96 *
97 * @param name tag name
98 * @param addNewLine option to add new line character after tag
99 * @return string
100 */
101 public static String buildEndTag(String name, boolean addNewLine) {
102 if (addNewLine) {
103 return (ANGLE_LEFT + SLASH + name + ANGLE_RIGHT + NEW_LINE);
104 } else {
105 return (ANGLE_LEFT + SLASH + name + ANGLE_RIGHT);
106 }
107 }
108
109 /**
110 * Builds XML empty element tag with name provided.
111 *
112 * @param name tag name
113 * @param addNewLine option to add new line character after tag
114 * @return string
115 */
116 public static String buildEmptyTag(String name, boolean addNewLine) {
117 if (addNewLine) {
118 return (ANGLE_LEFT + name + SLASH + ANGLE_RIGHT + NEW_LINE);
119 } else {
120 return (ANGLE_LEFT + name + SLASH + ANGLE_RIGHT);
121 }
122 }
123
124}