Line data Source code
1 : // Copyright (C) 2009 The Android Open Source Project 2 : // 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 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.common.data; 16 : 17 : /** Class to store information about different source browser types. */ 18 153 : public class GitwebType { 19 : private String name; 20 : 21 : private String branch; 22 : private String file; 23 : private String fileHistory; 24 : private String project; 25 : private String revision; 26 : private String rootTree; 27 : private String tag; 28 : 29 153 : private char pathSeparator = '/'; 30 153 : private boolean urlEncode = true; 31 : 32 : /** Returns name displayed in links. */ 33 : public String getLinkName() { 34 0 : return name; 35 : } 36 : 37 : /** 38 : * Set the name displayed in links. 39 : * 40 : * @param name new name. 41 : */ 42 : public void setLinkName(String name) { 43 0 : this.name = name; 44 0 : } 45 : 46 : /** Returns parameterized string for the branch URL. */ 47 : public String getBranch() { 48 0 : return branch; 49 : } 50 : 51 : /** 52 : * Set the parameterized string for the branch URL. 53 : * 54 : * @param str new string. 55 : */ 56 : public void setBranch(String str) { 57 0 : branch = str; 58 0 : } 59 : 60 : /** Returns parameterized string for the tag URL. */ 61 : public String getTag() { 62 0 : return tag; 63 : } 64 : 65 : /** 66 : * Set the parameterized string for the tag URL. 67 : * 68 : * @param str new string. 69 : */ 70 : public void setTag(String str) { 71 0 : tag = str; 72 0 : } 73 : 74 : /** Returns parameterized string for the file URL. */ 75 : public String getFile() { 76 0 : return file; 77 : } 78 : 79 : /** 80 : * Set the parameterized string for the file URL. 81 : * 82 : * @param str new string. 83 : */ 84 : public void setFile(String str) { 85 0 : file = str; 86 0 : } 87 : 88 : /** Returns parameterized string for the file history URL. */ 89 : public String getFileHistory() { 90 0 : return fileHistory; 91 : } 92 : 93 : /** 94 : * Set the parameterized string for the file history URL. 95 : * 96 : * @param str new string. 97 : */ 98 : public void setFileHistory(String str) { 99 0 : fileHistory = str; 100 0 : } 101 : 102 : /** Returns parameterized string for the project URL. */ 103 : public String getProject() { 104 0 : return project; 105 : } 106 : 107 : /** 108 : * Set the parameterized string for the project URL. 109 : * 110 : * @param str new string. 111 : */ 112 : public void setProject(String str) { 113 0 : project = str; 114 0 : } 115 : 116 : /** Returns parameterized string for the revision URL. */ 117 : public String getRevision() { 118 0 : return revision; 119 : } 120 : 121 : /** 122 : * Set the parameterized string for the revision URL. 123 : * 124 : * @param str new string. 125 : */ 126 : public void setRevision(String str) { 127 0 : revision = str; 128 0 : } 129 : 130 : /** Returns parameterized string for the root tree URL. */ 131 : public String getRootTree() { 132 0 : return rootTree; 133 : } 134 : 135 : /** 136 : * Set the parameterized string for the root tree URL. 137 : * 138 : * @param str new string. 139 : */ 140 : public void setRootTree(String str) { 141 0 : rootTree = str; 142 0 : } 143 : 144 : /** Returns path separator used for branch and project names. */ 145 : public char getPathSeparator() { 146 0 : return pathSeparator; 147 : } 148 : 149 : /** 150 : * Set the custom path separator. 151 : * 152 : * @param separator new separator. 153 : */ 154 : public void setPathSeparator(char separator) { 155 1 : this.pathSeparator = separator; 156 1 : } 157 : 158 : /** Returns whether to URL encode path segments. */ 159 : public boolean getUrlEncode() { 160 0 : return urlEncode; 161 : } 162 : 163 : /** 164 : * Set whether to URL encode path segments. 165 : * 166 : * @param urlEncode new value. 167 : */ 168 : public void setUrlEncode(boolean urlEncode) { 169 0 : this.urlEncode = urlEncode; 170 0 : } 171 : 172 : /** 173 : * Replace standard path separator with custom configured path separator. 174 : * 175 : * @param urlSegment URL segment (e.g. branch or project name) in which to replace the path 176 : * separator. 177 : * @return the segment with the standard path separator replaced by the custom {@link 178 : * #getPathSeparator()}. 179 : */ 180 : public String replacePathSeparator(String urlSegment) { 181 1 : if ('/' != pathSeparator) { 182 1 : return urlSegment.replace('/', pathSeparator); 183 : } 184 1 : return urlSegment; 185 : } 186 : }