1/*2 * Copyright 2014 The Apache Software Foundation.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 at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */16package org.apache.juddi.v3.client.mapping;
1718import java.util.ArrayList;
19import java.util.List;
20import org.apache.juddi.v3.client.UDDIConstants;
21import org.uddi.api_v3.Description;
2223/**24 * Common parsing functions for converting to UDDI's data structures25 * @author Alex O'Ree26 */27publicabstractclassCommon2UDDI {
2829publicstatic List<Description> mapDescription(String content, String lang) {
3031 List<Description> ret = new ArrayList<Description>();
32if (content == null) {
33return ret;
34 }
35if (content.length() > UDDIConstants.MAX_description_length) {
36int offset = 0;
37while (offset < content.length()) {
38Description description = newDescription();
39 description.setLang(lang);
40int trim = offset + UDDIConstants.MAX_description_length;
41if (trim > content.length()) {
42 trim = content.length()-1;
43 }
44 description.setValue(content.substring(offset, trim));
45 offset = offset + UDDIConstants.MAX_description_length;
46 ret.add(description);
4748 }
49 } else {
50 ret.add(newDescription(content, lang));
51 }
52return ret;
5354 }
55 }