+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cadi.util;\r
-\r
-/**\r
- * Split by Char, optional Trim\r
- *\r
- * Note: Copied from Inno to avoid linking issues.\r
- * Note: I read the String split and Pattern split code, and we can do this more efficiently for a single Character\r
- * \r
- * 8/20/2015\r
- */\r
-\r
-public class Split {\r
- public static String[] split(char c, String value) {\r
- // Count items to preallocate Array (memory alloc is more expensive than counting twice)\r
- int count,idx;\r
- for(count=1,idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,++idx),++count);\r
- String[] rv = new String[count];\r
- if(count==1) {\r
- rv[0]=value;\r
- } else {\r
- int last=0;\r
- count=-1;\r
- for(idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,idx)) {\r
- rv[++count]=value.substring(last,idx);\r
- last = ++idx;\r
- }\r
- rv[++count]=value.substring(last);\r
- }\r
- return rv;\r
- }\r
-\r
- public static String[] splitTrim(char c, String value) {\r
- // Count items to preallocate Array (memory alloc is more expensive than counting twice)\r
- int count,idx;\r
- for(count=1,idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,++idx),++count);\r
- String[] rv = new String[count];\r
- if(count==1) {\r
- rv[0]=value.trim();\r
- } else {\r
- int last=0;\r
- count=-1;\r
- for(idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,idx)) {\r
- rv[++count]=value.substring(last,idx).trim();\r
- last = ++idx;\r
- }\r
- rv[++count]=value.substring(last).trim();\r
- }\r
- return rv;\r
- }\r
-\r
- public static String[] splitTrim(char c, String value, int size) {\r
- int idx;\r
- String[] rv = new String[size];\r
- if(size==1) {\r
- rv[0]=value.trim();\r
- } else {\r
- int last=0;\r
- int count=-1;\r
- size-=2;\r
- for(idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {\r
- rv[++count]=value.substring(last,idx).trim();\r
- last = ++idx;\r
- }\r
- rv[++count]=value.substring(last).trim();\r
- }\r
- return rv;\r
- }\r
-\r
-}\r