Skip to content

Commit

Permalink
License headers and other legal stuff (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbarny authored Aug 16, 2019
1 parent c6068fb commit a859c6b
Show file tree
Hide file tree
Showing 25 changed files with 541 additions and 92 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2019 Elastic and contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
43 changes: 43 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
java-ecs-logging
Copyright 2019 Elasticsearch B.V.

###############################################################################
This product includes software licensed under the Apache License 2.0 developed at FasterXML.

Jackson LICENSE:
-------------------------------------------------------------------------------
This copy of Jackson JSON processor streaming parser/generator is licensed under the
Apache (Software) License, version 2.0 ("the License").
See the License for details about distribution rights, and the
specific rights regarding derivate works.

You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0
-------------------------------------------------------------------------------


Jackson NOTICE:
-------------------------------------------------------------------------------
# Jackson JSON processor

Jackson is a high-performance, Free/Open Source JSON processing library.
It was originally written by Tatu Saloranta ([email protected]), and has
been in development since 2007.
It is currently developed by a community of developers, as well as supported
commercially by FasterXML.com.

## Licensing

Jackson core and extension components may licensed under different licenses.
To find the details that apply to this artifact see the accompanying LICENSE file.
For more information, including possible other licensing options, contact
FasterXML.com (http://fasterxml.com).

## Credits

A list of contributors may be found from CREDITS file, which is included
in some artifacts (usually source distributions); but is always available
from the source code management (SCM) system project uses.
-------------------------------------------------------------------------------
###############################################################################
3 changes: 3 additions & 0 deletions ecs-logging-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>ecs-logging-core</artifactId>
<properties>
<parent.base.dir>${project.basedir}/..</parent.base.dir>
</properties>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
/*-
* #%L
* Java ECS logging
* %%
* Copyright (C) 2019 Elastic and contributors
* %%
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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.
* #L%
*/
package co.elastic.logging;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -115,4 +137,4 @@ private static CharSequence formatThrowable(final Throwable throwable) {
pw.flush();
return sw.toString();
}
}
}
132 changes: 61 additions & 71 deletions ecs-logging-core/src/main/java/co/elastic/logging/JsonUtils.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
/*-
* #%L
* Java ECS logging
* %%
* Copyright (C) 2019 Elastic and contributors
* %%
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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.
* #L%
*/
package co.elastic.logging;

/**
* This class is borrowed from <a href="https://github.com/FasterXML/jackson-core">Jackson</a>.
* This class is based on com.fasterxml.jackson.core.io.CharTypes,
* under Apache License 2.0
*/
public final class JsonUtils {

private static final char[] HC = "0123456789ABCDEF".toCharArray();
private final static char[] HC = "0123456789ABCDEF".toCharArray();

/**
* Read-only encoding table for first 128 Unicode code points (single-byte UTF-8 characters).
* Value of 0 means "no escaping"; other positive values that value is character
* to use after backslash; and negative values that generic (backslash - u)
* escaping is to be used.
* Lookup table used for determining which output characters in
* 7-bit ASCII range need to be quoted.
*/
private static final int[] ESC_CODES;
private final static int[] sOutputEscapes128;

static {
final int[] table = new int[128];
int[] table = new int[128];
// Control chars need generic escape sequence
for (int i = 0; i < 32; ++i) {
// 04-Mar-2011, tatu: Used to use "-(i + 1)", replaced with constant
table[i] = -1;
}
/* Others (and some within that range too) have explicit shorter
* sequences
*/
// Others (and some within that range too) have explicit shorter sequences
table['"'] = '"';
table['\\'] = '\\';
// Escaping of slash is optional, so let's not add it
Expand All @@ -32,72 +54,40 @@ public final class JsonUtils {
table[0x0C] = 'f';
table[0x0A] = 'n';
table[0x0D] = 'r';
ESC_CODES = table;
}

/**
* Temporary buffer used for composing quote/escape sequences
*/
private final static ThreadLocal<char[]> _qbufLocal = new ThreadLocal<>();

private static char[] getQBuf() {
char[] _qbuf = _qbufLocal.get();
if (_qbuf == null) {
_qbuf = new char[6];
_qbuf[0] = '\\';
_qbuf[2] = '0';
_qbuf[3] = '0';

_qbufLocal.set(_qbuf);
}
return _qbuf;
sOutputEscapes128 = table;
}

/**
* Quote text contents using JSON standard quoting, and append results to a supplied {@link StringBuilder}.
*/
public static void quoteAsString(final CharSequence input, final StringBuilder output) {
final char[] qbuf = getQBuf();
final int escCodeCount = ESC_CODES.length;
int inPtr = 0;
final int inputLen = input.length();

outer:
while (inPtr < inputLen) {
tight_loop:
while (true) {
final char c = input.charAt(inPtr);
if (c < escCodeCount && ESC_CODES[c] != 0) {
break tight_loop;
}
output.append(c);
if (++inPtr >= inputLen) {
break outer;
}
public static void quoteAsString(CharSequence content, StringBuilder sb) {
final int[] escCodes = sOutputEscapes128;
final int escLen = escCodes.length;
for (int i = 0, len = content.length(); i < len; ++i) {
char c = content.charAt(i);
if (c >= escLen || escCodes[c] == 0) {
sb.append(c);
continue;
}
// something to escape; 2 or 6-char variant?
final char d = input.charAt(inPtr++);
final int escCode = ESC_CODES[d];
final int length = (escCode < 0)
? _appendNumeric(d, qbuf)
: _appendNamed(escCode, qbuf);
sb.append('\\');
int escCode = escCodes[c];
if (escCode < 0) { // generic quoting (hex value)
// The only negative value sOutputEscapes128 returns
// is CharacterEscapes.ESCAPE_STANDARD, which mean
// appendQuotes should encode using the Unicode encoding;
// not sure if this is the right way to encode for
// CharacterEscapes.ESCAPE_CUSTOM or other (future)
// CharacterEscapes.ESCAPE_XXX values.

output.append(qbuf, 0, length);
// We know that it has to fit in just 2 hex chars
sb.append('u');
sb.append('0');
sb.append('0');
int value = c; // widening
sb.append(HC[value >> 4]);
sb.append(HC[value & 0xF]);
} else { // "named", i.e. prepend with slash
sb.append((char) escCode);
}
}
}

private static int _appendNumeric(final int value, final char[] qbuf) {
qbuf[1] = 'u';
// We know it's a control char, so only the last 2 chars are non-0
qbuf[4] = HC[value >> 4];
qbuf[5] = HC[value & 0xF];
return 6;
}

private static int _appendNamed(final int esc, final char[] qbuf) {
qbuf[1] = (char) esc;
return 2;
}

}

Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*-
* #%L
* Java ECS logging
* %%
* Copyright (C) 2019 Elastic and contributors
* %%
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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.
* #L%
*/
package co.elastic.logging;

import java.text.SimpleDateFormat;
Expand Down
44 changes: 44 additions & 0 deletions ecs-logging-core/src/main/resources/META-INF/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
java-ecs-logging
Copyright 2019 Elasticsearch B.V.

###############################################################################
This product includes software licensed under the Apache License 2.0 developed at FasterXML.
- co.elastic.logging.JsonUtils

Jackson LICENSE:
-------------------------------------------------------------------------------
This copy of Jackson JSON processor streaming parser/generator is licensed under the
Apache (Software) License, version 2.0 ("the License").
See the License for details about distribution rights, and the
specific rights regarding derivate works.

You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0
-------------------------------------------------------------------------------


Jackson NOTICE:
-------------------------------------------------------------------------------
# Jackson JSON processor

Jackson is a high-performance, Free/Open Source JSON processing library.
It was originally written by Tatu Saloranta ([email protected]), and has
been in development since 2007.
It is currently developed by a community of developers, as well as supported
commercially by FasterXML.com.

## Licensing

Jackson core and extension components may licensed under different licenses.
To find the details that apply to this artifact see the accompanying LICENSE file.
For more information, including possible other licensing options, contact
FasterXML.com (http://fasterxml.com).

## Credits

A list of contributors may be found from CREDITS file, which is included
in some artifacts (usually source distributions); but is always available
from the source code management (SCM) system project uses.
-------------------------------------------------------------------------------
###############################################################################
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*-
* #%L
* Java ECS logging
* %%
* Copyright (C) 2019 Elastic and contributors
* %%
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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.
* #L%
*/
package co.elastic.logging;


Expand Down
Loading

0 comments on commit a859c6b

Please sign in to comment.