Skip to content
Permalink
Browse files
This closes #640
  • Loading branch information
clebertsuconic committed Jul 26, 2016
2 parents e664780 + d0ecf0f commit 110158bb8626a99fc988ca84f29f28e903b39dd9
Showing 50 changed files with 1,039 additions and 3,706 deletions.
28 LICENSE
@@ -201,34 +201,6 @@
See the License for the specific language governing permissions and
limitations under the License.

===============================================================
= For json processor files. =
= See: src/main/java/org/apache/activemq/utils/json =
===============================================================

Copyright (c) 2002 JSON.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

The Software shall be used for Good, not Evil.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


===============================================================
= For Base64.java file =
===============================================================
@@ -0,0 +1,108 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.activemq.artemis.utils;

public abstract class StringEscapeUtils {
/**
* Adapted from commons lang StringEscapeUtils, escapes a string
*
* @param str
* @return an escaped version of the input string.
*/
public static String escapeString(String str) {
if (str == null) {
return str;
}
int sz = str.length();
StringBuilder stringBuilder = new StringBuilder(str.length());
for (int i = 0; i < sz; i++) {
char ch = str.charAt(i);

// handle unicode
if (ch > 0xfff) {
stringBuilder.append("\\u").append(hex(ch));
}
else if (ch > 0xff) {
stringBuilder.append("\\u0").append(hex(ch));
}
else if (ch > 0x7f) {
stringBuilder.append("\\u00").append(hex(ch));
}
else if (ch < 32) {
switch (ch) {
case '\b':
stringBuilder.append('\\').append('b');
break;
case '\n':
stringBuilder.append('\\').append('n');
break;
case '\t':
stringBuilder.append('\\').append('t');
break;
case '\f':
stringBuilder.append('\\').append('f');
break;
case '\r':
stringBuilder.append('\\').append('r');
break;
default :
if (ch > 0xf) {
stringBuilder.append("\\u00").append(hex(ch));
}
else {
stringBuilder.append("\\u000").append(hex(ch));
}
break;
}
}
else {
switch (ch) {
case '\'':
stringBuilder.append('\\').append('\'');
break;
case '"':
stringBuilder.append('\\').append('"');
break;
case '\\':
stringBuilder.append('\\').append('\\');
break;
case '/':
stringBuilder.append('\\').append('/');
break;
default :
stringBuilder.append(ch);
break;
}
}
}
return stringBuilder.toString();
}

/**
* <p>Returns an upper case hexadecimal <code>String</code> for the given
* character.</p>
*
* @param ch The character to convert.
* @return An upper case hexadecimal <code>String</code>
*/
private static String hex(char ch) {
return Integer.toHexString(ch).toUpperCase();
}
}
@@ -68,6 +68,14 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-json_1.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-core</artifactId>
</dependency>
</dependencies>

<profiles>

0 comments on commit 110158b

Please sign in to comment.