Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.drivers.fujitsu; |
| 18 | |
| 19 | /** |
| 20 | * Defines common XML constants and methods for Fujitsu vOLT. |
| 21 | */ |
| 22 | public 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 | |
xueliang | 5b3d3444 | 2016-09-23 10:37:33 +0900 | [diff] [blame] | 45 | public static final int FIRST_PART = 0; |
| 46 | public static final int SECOND_PART = 1; |
| 47 | public static final int THIRD_PART = 2; |
| 48 | public static final int ZERO = 0; |
| 49 | public static final int ONE = 1; |
| 50 | public static final int TWO = 2; |
| 51 | public static final int THREE = 3; |
| 52 | |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 53 | private FujitsuVoltXmlUtility() { |
| 54 | // Preventing any allocation |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Builds XML start tag with name provided. |
| 59 | * |
| 60 | * @param name tag name |
| 61 | * @return string |
| 62 | */ |
| 63 | public static String buildStartTag(String name) { |
| 64 | return buildStartTag(name, true); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Builds XML end tag with name provided. |
| 69 | * |
| 70 | * @param name tag name |
| 71 | * @return string |
| 72 | */ |
| 73 | public static String buildEndTag(String name) { |
| 74 | return buildEndTag(name, true); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Builds XML empty tag with name provided. |
| 79 | * |
| 80 | * @param name tag name |
| 81 | * @return string |
| 82 | */ |
| 83 | public static String buildEmptyTag(String name) { |
| 84 | return buildEmptyTag(name, true); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Builds XML start tag with name provided. |
| 89 | * |
| 90 | * @param name tag name |
| 91 | * @param addNewLine option to add new line character after tag |
| 92 | * @return string |
| 93 | */ |
| 94 | public static String buildStartTag(String name, boolean addNewLine) { |
| 95 | if (addNewLine) { |
| 96 | return (ANGLE_LEFT + name + ANGLE_RIGHT + NEW_LINE); |
| 97 | } else { |
| 98 | return (ANGLE_LEFT + name + ANGLE_RIGHT); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Builds XML end tag with name provided. |
| 104 | * |
| 105 | * @param name tag name |
| 106 | * @param addNewLine option to add new line character after tag |
| 107 | * @return string |
| 108 | */ |
| 109 | public static String buildEndTag(String name, boolean addNewLine) { |
| 110 | if (addNewLine) { |
| 111 | return (ANGLE_LEFT + SLASH + name + ANGLE_RIGHT + NEW_LINE); |
| 112 | } else { |
| 113 | return (ANGLE_LEFT + SLASH + name + ANGLE_RIGHT); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Builds XML empty element tag with name provided. |
| 119 | * |
| 120 | * @param name tag name |
| 121 | * @param addNewLine option to add new line character after tag |
| 122 | * @return string |
| 123 | */ |
| 124 | public static String buildEmptyTag(String name, boolean addNewLine) { |
| 125 | if (addNewLine) { |
| 126 | return (ANGLE_LEFT + name + SLASH + ANGLE_RIGHT + NEW_LINE); |
| 127 | } else { |
| 128 | return (ANGLE_LEFT + name + SLASH + ANGLE_RIGHT); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | } |