View Javadoc
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 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  package org.apache.juddi.v3.client.mapping;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import org.apache.juddi.v3.client.UDDIConstants;
21  import org.uddi.api_v3.Description;
22  
23  /**
24   * Common parsing functions for converting to UDDI's data structures
25   * @author Alex O'Ree
26   */
27  public abstract class Common2UDDI {
28  
29          public static List<Description> mapDescription(String content, String lang) {
30  
31                  List<Description> ret = new ArrayList<Description>();
32                  if (content == null) {
33                          return ret;
34                  }
35                  if (content.length() > UDDIConstants.MAX_description_length) {
36                          int offset = 0;
37                          while (offset < content.length()) {
38                                  Description description = new Description();
39                                  description.setLang(lang);
40                                  int trim = offset + UDDIConstants.MAX_description_length;
41                                  if (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);
47                                  
48                          }
49                  } else {
50                          ret.add(new Description(content, lang));
51                  }
52                  return ret;
53  
54          }
55  }