You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/09/09 13:20:11 UTC
[11/15] cut down the included source code from javolution (no more
OSGi dependencies) and updated NOTICE and LICENSE files in source root
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8ByteBufferReader.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8ByteBufferReader.java b/commons/marmotta-commons/src/ext/java/javolution/io/UTF8ByteBufferReader.java
deleted file mode 100644
index 5defa8c..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8ByteBufferReader.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.io;
-
-import java.io.CharConversionException;
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-
-/**
- * <p> A UTF-8 <code>java.nio.ByteBuffer</code> reader.
- * </p>
- *
- * <p> This reader can be used for efficient decoding of native byte
- * buffers (e.g. <code>MappedByteBuffer</code>), high-performance
- * messaging (no intermediate buffer), etc.</p>
- *
- * <p> This reader supports surrogate <code>char</code> pairs (representing
- * characters in the range [U+10000 .. U+10FFFF]). It can also be used
- * to read characters unicodes (31 bits) directly
- * (ref. {@link #read()}).</p>
- *
- * <p> Each invocation of one of the <code>read()</code> methods may cause one
- * or more bytes to be read from the underlying byte buffer.
- * The end of stream is reached when the byte buffer position and limit
- * coincide.</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 2.0, December 9, 2004
- * @see UTF8ByteBufferWriter
- */
-public final class UTF8ByteBufferReader extends Reader {
-
- /**
- * Holds the byte buffer source.
- */
- private ByteBuffer _byteBuffer;
-
- /**
- * Default constructor.
- */
- public UTF8ByteBufferReader() {}
-
- /**
- * Sets the <code>ByteBuffer</code> to use for reading available bytes
- * from current buffer position.
- *
- * @param byteBuffer the <code>ByteBuffer</code> source.
- * @return this UTF-8 reader.
- * @throws IllegalStateException if this reader is being reused and
- * it has not been {@link #close closed} or {@link #reset reset}.
- */
- public UTF8ByteBufferReader setInput(ByteBuffer byteBuffer) {
- if (_byteBuffer != null)
- throw new IllegalStateException("Reader not closed or reset");
- _byteBuffer = byteBuffer;
- return this;
- }
-
- /**
- * Indicates if this stream is ready to be read.
- *
- * @return <code>true</code> if the byte buffer has remaining bytes to
- * read; <code>false</code> otherwise.
- * @throws IOException if an I/O error occurs.
- */
- public boolean ready() throws IOException {
- if (_byteBuffer != null) {
- return _byteBuffer.hasRemaining();
- } else {
- throw new IOException("Reader closed");
- }
- }
-
- /**
- * Closes and {@link #reset resets} this reader for reuse.
- *
- * @throws IOException if an I/O error occurs.
- */
- public void close() throws IOException {
- if (_byteBuffer != null) {
- reset();
- }
- }
-
- /**
- * Reads a single character. This method does not block, <code>-1</code>
- * is returned if the buffer's limit has been reached.
- *
- * @return the 31-bits Unicode of the character read, or -1 if there is
- * no more remaining bytes to be read.
- * @throws IOException if an I/O error occurs (e.g. incomplete
- * character sequence being read).
- */
- public int read() throws IOException {
- if (_byteBuffer != null) {
- if (_byteBuffer.hasRemaining()) {
- byte b = _byteBuffer.get();
- return (b >= 0) ? b : read2(b);
- } else {
- return -1;
- }
- } else {
- throw new IOException("Reader closed");
- }
- }
-
- // Reads one full character, throws CharConversionException if limit reached.
- private int read2(byte b) throws IOException {
- try {
- // Decodes UTF-8.
- if ((b >= 0) && (_moreBytes == 0)) {
- // 0xxxxxxx
- return b;
- } else if (((b & 0xc0) == 0x80) && (_moreBytes != 0)) {
- // 10xxxxxx (continuation byte)
- _code = (_code << 6) | (b & 0x3f); // Adds 6 bits to code.
- if (--_moreBytes == 0) {
- return _code;
- } else {
- return read2(_byteBuffer.get());
- }
- } else if (((b & 0xe0) == 0xc0) && (_moreBytes == 0)) {
- // 110xxxxx
- _code = b & 0x1f;
- _moreBytes = 1;
- return read2(_byteBuffer.get());
- } else if (((b & 0xf0) == 0xe0) && (_moreBytes == 0)) {
- // 1110xxxx
- _code = b & 0x0f;
- _moreBytes = 2;
- return read2(_byteBuffer.get());
- } else if (((b & 0xf8) == 0xf0) && (_moreBytes == 0)) {
- // 11110xxx
- _code = b & 0x07;
- _moreBytes = 3;
- return read2(_byteBuffer.get());
- } else if (((b & 0xfc) == 0xf8) && (_moreBytes == 0)) {
- // 111110xx
- _code = b & 0x03;
- _moreBytes = 4;
- return read2(_byteBuffer.get());
- } else if (((b & 0xfe) == 0xfc) && (_moreBytes == 0)) {
- // 1111110x
- _code = b & 0x01;
- _moreBytes = 5;
- return read2(_byteBuffer.get());
- } else {
- throw new CharConversionException("Invalid UTF-8 Encoding");
- }
- } catch (BufferUnderflowException e) {
- throw new CharConversionException("Incomplete Sequence");
- }
- }
-
- private int _code;
-
- private int _moreBytes;
-
- /**
- * Reads characters into a portion of an array. This method does not
- * block.
- *
- * <p> Note: Characters between U+10000 and U+10FFFF are represented
- * by surrogate pairs (two <code>char</code>).</p>
- *
- * @param cbuf the destination buffer.
- * @param off the offset at which to start storing characters.
- * @param len the maximum number of characters to read
- * @return the number of characters read, or -1 if there is no more
- * byte remaining.
- * @throws IOException if an I/O error occurs.
- */
- public int read(char cbuf[], int off, int len) throws IOException {
- if (_byteBuffer == null)
- throw new IOException("Reader closed");
- final int off_plus_len = off + len;
- int remaining = _byteBuffer.remaining();
- if (remaining <= 0)
- return -1;
- for (int i = off; i < off_plus_len;) {
- if (remaining-- > 0) {
- byte b = _byteBuffer.get();
- if (b >= 0) {
- cbuf[i++] = (char) b; // Most common case.
- } else {
- if (i < off_plus_len - 1) { // Up to two 'char' can be read.
- int code = read2(b);
- remaining = _byteBuffer.remaining(); // Recalculates.
- if (code < 0x10000) {
- cbuf[i++] = (char) code;
- } else if (code <= 0x10ffff) { // Surrogates.
- cbuf[i++] = (char) (((code - 0x10000) >> 10) + 0xd800);
- cbuf[i++] = (char) (((code - 0x10000) & 0x3ff) + 0xdc00);
- } else {
- throw new CharConversionException(
- "Cannot convert U+"
- + Integer.toHexString(code)
- + " to char (code greater than U+10FFFF)");
- }
- } else { // Not enough space in destination (go back).
- _byteBuffer.position(_byteBuffer.position() - 1);
- remaining++;
- return i - off;
- }
- }
- } else {
- return i - off;
- }
- }
- return len;
- }
-
- /**
- * Reads characters into the specified appendable. This method does not
- * block.
- *
- * <p> Note: Characters between U+10000 and U+10FFFF are represented
- * by surrogate pairs (two <code>char</code>).</p>
- *
- * @param dest the destination buffer.
- * @throws IOException if an I/O error occurs.
- */
- public void read(Appendable dest) throws IOException {
- if (_byteBuffer == null)
- throw new IOException("Reader closed");
- while (_byteBuffer.hasRemaining()) {
- byte b = _byteBuffer.get();
- if (b >= 0) {
- dest.append((char) b); // Most common case.
- } else {
- int code = read2(b);
- if (code < 0x10000) {
- dest.append((char) code);
- } else if (code <= 0x10ffff) { // Surrogates.
- dest.append((char) (((code - 0x10000) >> 10) + 0xd800));
- dest.append((char) (((code - 0x10000) & 0x3ff) + 0xdc00));
- } else {
- throw new CharConversionException("Cannot convert U+"
- + Integer.toHexString(code)
- + " to char (code greater than U+10FFFF)");
- }
- }
- }
- }
-
- public void reset() {
- _byteBuffer = null;
- _code = 0;
- _moreBytes = 0;
- }
-
- /**
- * @deprecated Replaced by {@link #setInput(ByteBuffer)}
- */
- public UTF8ByteBufferReader setByteBuffer(ByteBuffer byteBuffer) {
- return this.setInput(byteBuffer);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8ByteBufferWriter.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8ByteBufferWriter.java b/commons/marmotta-commons/src/ext/java/javolution/io/UTF8ByteBufferWriter.java
deleted file mode 100644
index 5765c41..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8ByteBufferWriter.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.io;
-
-import java.io.CharConversionException;
-import java.io.IOException;
-import java.io.Writer;
-import java.nio.ByteBuffer;
-
-/**
- * <p> A UTF-8 <code>java.nio.ByteBuffer</code> writer.</p>
- *
- * <p> This writer supports surrogate <code>char</code> pairs (representing
- * characters in the range [U+10000 .. U+10FFFF]). It can also be used
- * to write characters from their unicodes (31 bits) directly
- * (ref. {@link #write(int)}).</p>
- *
- * <p> Instances of this class can be reused for different output streams
- * and can be part of a higher level component (e.g. serializer) in order
- * to avoid dynamic buffer allocation when the destination output changes.
- * Also wrapping using a <code>java.io.BufferedWriter</code> is unnescessary
- * as instances of this class embed their own data buffers.</p>
- *
- * <p> Note: This writer is unsynchronized and always produces well-formed
- * UTF-8 sequences.</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 2.0, December 9, 2004
- * @see UTF8ByteBufferReader
- */
-public final class UTF8ByteBufferWriter extends Writer {
-
- /**
- * Holds the byte buffer destination.
- */
- private ByteBuffer _byteBuffer;
-
- /**
- * Default constructor.
- */
- public UTF8ByteBufferWriter() {}
-
- /**
- * Sets the byte buffer to use for writing until this writer is closed.
- *
- * @param byteBuffer the destination byte buffer.
- * @return this UTF-8 writer.
- * @throws IllegalStateException if this writer is being reused and
- * it has not been {@link #close closed} or {@link #reset reset}.
- */
- public UTF8ByteBufferWriter setOutput(ByteBuffer byteBuffer) {
- if (_byteBuffer != null)
- throw new IllegalStateException("Writer not closed or reset");
- _byteBuffer = byteBuffer;
- return this;
- }
-
- /**
- * Writes a single character. This method supports 16-bits
- * character surrogates.
- *
- * @param c <code>char</code> the character to be written (possibly
- * a surrogate).
- * @throws IOException if an I/O error occurs.
- */
- public void write(char c) throws IOException {
- if ((c < 0xd800) || (c > 0xdfff)) {
- write((int) c);
- } else if (c < 0xdc00) { // High surrogate.
- _highSurrogate = c;
- } else { // Low surrogate.
- int code = ((_highSurrogate - 0xd800) << 10) + (c - 0xdc00)
- + 0x10000;
- write(code);
- }
- }
-
- private char _highSurrogate;
-
- /**
- * Writes a character given its 31-bits Unicode.
- *
- * @param code the 31 bits Unicode of the character to be written.
- * @throws IOException if an I/O error occurs.
- */
- public void write(int code) throws IOException {
- if ((code & 0xffffff80) == 0) {
- _byteBuffer.put((byte) code);
- } else { // Writes more than one byte.
- write2(code);
- }
- }
-
- private void write2(int c) throws IOException {
- if ((c & 0xfffff800) == 0) { // 2 bytes.
- _byteBuffer.put((byte) (0xc0 | (c >> 6)));
- _byteBuffer.put((byte) (0x80 | (c & 0x3f)));
- } else if ((c & 0xffff0000) == 0) { // 3 bytes.
- _byteBuffer.put((byte) (0xe0 | (c >> 12)));
- _byteBuffer.put((byte) (0x80 | ((c >> 6) & 0x3f)));
- _byteBuffer.put((byte) (0x80 | (c & 0x3f)));
- } else if ((c & 0xff200000) == 0) { // 4 bytes.
- _byteBuffer.put((byte) (0xf0 | (c >> 18)));
- _byteBuffer.put((byte) (0x80 | ((c >> 12) & 0x3f)));
- _byteBuffer.put((byte) (0x80 | ((c >> 6) & 0x3f)));
- _byteBuffer.put((byte) (0x80 | (c & 0x3f)));
- } else if ((c & 0xf4000000) == 0) { // 5 bytes.
- _byteBuffer.put((byte) (0xf8 | (c >> 24)));
- _byteBuffer.put((byte) (0x80 | ((c >> 18) & 0x3f)));
- _byteBuffer.put((byte) (0x80 | ((c >> 12) & 0x3f)));
- _byteBuffer.put((byte) (0x80 | ((c >> 6) & 0x3f)));
- _byteBuffer.put((byte) (0x80 | (c & 0x3f)));
- } else if ((c & 0x80000000) == 0) { // 6 bytes.
- _byteBuffer.put((byte) (0xfc | (c >> 30)));
- _byteBuffer.put((byte) (0x80 | ((c >> 24) & 0x3f)));
- _byteBuffer.put((byte) (0x80 | ((c >> 18) & 0x3f)));
- _byteBuffer.put((byte) (0x80 | ((c >> 12) & 0x3F)));
- _byteBuffer.put((byte) (0x80 | ((c >> 6) & 0x3F)));
- _byteBuffer.put((byte) (0x80 | (c & 0x3F)));
- } else {
- throw new CharConversionException("Illegal character U+"
- + Integer.toHexString(c));
- }
- }
-
- /**
- * Writes a portion of an array of characters.
- *
- * @param cbuf the array of characters.
- * @param off the offset from which to start writing characters.
- * @param len the number of characters to write.
- * @throws IOException if an I/O error occurs.
- */
- public void write(char cbuf[], int off, int len) throws IOException {
- final int off_plus_len = off + len;
- for (int i = off; i < off_plus_len;) {
- char c = cbuf[i++];
- if (c < 0x80) {
- _byteBuffer.put((byte) c);
- } else {
- write(c);
- }
- }
- }
-
- /**
- * Writes a portion of a string.
- *
- * @param str a String.
- * @param off the offset from which to start writing characters.
- * @param len the number of characters to write.
- * @throws IOException if an I/O error occurs
- */
- public void write(String str, int off, int len) throws IOException {
- final int off_plus_len = off + len;
- for (int i = off; i < off_plus_len;) {
- char c = str.charAt(i++);
- if (c < 0x80) {
- _byteBuffer.put((byte) c);
- } else {
- write(c);
- }
- }
- }
-
- /**
- * Writes the specified character sequence.
- *
- * @param csq the character sequence.
- * @throws IOException if an I/O error occurs
- */
- public void write(CharSequence csq) throws IOException {
- final int length = csq.length();
- for (int i = 0; i < length;) {
- char c = csq.charAt(i++);
- if (c < 0x80) {
- _byteBuffer.put((byte) c);
- } else {
- write(c);
- }
- }
- }
-
- /**
- * Flushes the stream (this method has no effect, the data is
- * always directly written to the <code>ByteBuffer</code>).
- *
- * @throws IOException if an I/O error occurs.
- */
- public void flush() throws IOException {
- if (_byteBuffer == null) { throw new IOException("Writer closed"); }
- }
-
- /**
- * Closes and {@link #reset resets} this writer for reuse.
- *
- * @throws IOException if an I/O error occurs
- */
- public void close() throws IOException {
- if (_byteBuffer != null) {
- reset();
- }
- }
-
- // Implements Reusable.
- public void reset() {
- _byteBuffer = null;
- _highSurrogate = 0;
- }
-
- /**
- * @deprecated Replaced by {@link #setOutput(ByteBuffer)}
- */
- public UTF8ByteBufferWriter setByteBuffer(ByteBuffer byteBuffer) {
- return this.setOutput(byteBuffer);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8StreamReader.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8StreamReader.java b/commons/marmotta-commons/src/ext/java/javolution/io/UTF8StreamReader.java
deleted file mode 100644
index 61fa4fb..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8StreamReader.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.io;
-
-import java.io.CharConversionException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-/**
- * <p> A UTF-8 stream reader.</p>
- *
- * <p> This reader supports surrogate <code>char</code> pairs (representing
- * characters in the range [U+10000 .. U+10FFFF]). It can also be used
- * to read characters unicodes (31 bits) directly
- * (ref. {@link #read()}).</p>
- *
- * <p> Each invocation of one of the <code>read()</code> methods may cause one
- * or more bytes to be read from the underlying byte-input stream.
- * To enable the efficient conversion of bytes to characters, more bytes may
- * be read ahead from the underlying stream than are necessary to satisfy
- * the current read operation.</p>
- *
- * <p> Instances of this class can be reused for different input streams
- * and can be part of a higher level component (e.g. parser) in order
- * to avoid dynamic buffer allocation when the input source changes.
- * Also wrapping using a <code>java.io.BufferedReader</code> is unnescessary
- * as instances of this class embed their own data buffers.</p>
- *
- * <p> Note: This reader is unsynchronized and does not test if the UTF-8
- * encoding is well-formed (e.g. UTF-8 sequences longer than
- * necessary to encode a character).</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 2.0, December 9, 2004
- * @see UTF8StreamWriter
- */
-public final class UTF8StreamReader extends Reader {
-
- /**
- * Holds the current input stream or <code>null</code> if closed.
- */
- private InputStream _inputStream;
-
- /**
- * Holds the start index.
- */
- private int _start;
-
- /**
- * Holds the end index.
- */
- private int _end;
-
- /**
- * Holds the bytes buffer.
- */
- private final byte[] _bytes;
-
- /**
- * Creates a UTF-8 reader having a byte buffer of moderate capacity (2048).
- */
- public UTF8StreamReader() {
- _bytes = new byte[2048];
- }
-
- /**
- * Creates a UTF-8 reader having a byte buffer of specified capacity.
- *
- * @param capacity the capacity of the byte buffer.
- */
- public UTF8StreamReader(int capacity) {
- _bytes = new byte[capacity];
- }
-
- /**
- * Sets the input stream to use for reading until this reader is closed.
- * For example:[code]
- * Reader reader = new UTF8StreamReader().setInput(inStream);
- * [/code] is equivalent but reads twice as fast as [code]
- * Reader reader = new java.io.InputStreamReader(inStream, "UTF-8");
- * [/code]
- *
- * @param inStream the input stream.
- * @return this UTF-8 reader.
- * @throws IllegalStateException if this reader is being reused and
- * it has not been {@link #close closed} or {@link #reset reset}.
- */
- public UTF8StreamReader setInput(InputStream inStream) {
- if (_inputStream != null)
- throw new IllegalStateException("Reader not closed or reset");
- _inputStream = inStream;
- return this;
- }
-
- /**
- * Indicates if this stream is ready to be read.
- *
- * @return <code>true</code> if the next read() is guaranteed not to block
- * for input; <code>false</code> otherwise.
- * @throws IOException if an I/O error occurs.
- */
- public boolean ready() throws IOException {
- if (_inputStream == null)
- throw new IOException("Stream closed");
- return ((_end - _start) > 0) || (_inputStream.available() != 0);
- }
-
- /**
- * Closes and {@link #reset resets} this reader for reuse.
- *
- * @throws IOException if an I/O error occurs.
- */
- public void close() throws IOException {
- if (_inputStream != null) {
- _inputStream.close();
- reset();
- }
- }
-
- /**
- * Reads a single character. This method will block until a character is
- * available, an I/O error occurs or the end of the stream is reached.
- *
- * @return the 31-bits Unicode of the character read, or -1 if the end of
- * the stream has been reached.
- * @throws IOException if an I/O error occurs.
- */
- public int read() throws IOException {
- byte b = _bytes[_start];
- return ((b >= 0) && (_start++ < _end)) ? b : read2();
- }
-
- // Reads one full character, blocks if necessary.
- private int read2() throws IOException {
- if (_start < _end) {
- byte b = _bytes[_start++];
-
- // Decodes UTF-8.
- if ((b >= 0) && (_moreBytes == 0)) {
- // 0xxxxxxx
- return b;
- } else if (((b & 0xc0) == 0x80) && (_moreBytes != 0)) {
- // 10xxxxxx (continuation byte)
- _code = (_code << 6) | (b & 0x3f); // Adds 6 bits to code.
- if (--_moreBytes == 0) {
- return _code;
- } else {
- return read2();
- }
- } else if (((b & 0xe0) == 0xc0) && (_moreBytes == 0)) {
- // 110xxxxx
- _code = b & 0x1f;
- _moreBytes = 1;
- return read2();
- } else if (((b & 0xf0) == 0xe0) && (_moreBytes == 0)) {
- // 1110xxxx
- _code = b & 0x0f;
- _moreBytes = 2;
- return read2();
- } else if (((b & 0xf8) == 0xf0) && (_moreBytes == 0)) {
- // 11110xxx
- _code = b & 0x07;
- _moreBytes = 3;
- return read2();
- } else if (((b & 0xfc) == 0xf8) && (_moreBytes == 0)) {
- // 111110xx
- _code = b & 0x03;
- _moreBytes = 4;
- return read2();
- } else if (((b & 0xfe) == 0xfc) && (_moreBytes == 0)) {
- // 1111110x
- _code = b & 0x01;
- _moreBytes = 5;
- return read2();
- } else {
- throw new CharConversionException("Invalid UTF-8 Encoding");
- }
- } else { // No more bytes in buffer.
- if (_inputStream == null)
- throw new IOException("No input stream or stream closed");
- _start = 0;
- _end = _inputStream.read(_bytes, 0, _bytes.length);
- if (_end > 0) {
- return read2(); // Continues.
- } else { // Done.
- if (_moreBytes == 0) {
- return -1;
- } else { // Incomplete sequence.
- throw new CharConversionException(
- "Unexpected end of stream");
- }
- }
- }
- }
-
- private int _code;
-
- private int _moreBytes;
-
- /**
- * Reads characters into a portion of an array. This method will block
- * until some input is available, an I/O error occurs or the end of
- * the stream is reached.
- *
- * <p> Note: Characters between U+10000 and U+10FFFF are represented
- * by surrogate pairs (two <code>char</code>).</p>
- *
- * @param cbuf the destination buffer.
- * @param off the offset at which to start storing characters.
- * @param len the maximum number of characters to read
- * @return the number of characters read, or -1 if the end of the
- * stream has been reached
- * @throws IOException if an I/O error occurs.
- */
- public int read(char cbuf[], int off, int len) throws IOException {
- if (_inputStream == null)
- throw new IOException("No input stream or stream closed");
- if (_start >= _end) { // Fills buffer.
- _start = 0;
- _end = _inputStream.read(_bytes, 0, _bytes.length);
- if (_end <= 0) { // Done.
- return _end;
- }
- }
- final int off_plus_len = off + len;
- for (int i = off; i < off_plus_len;) {
- // assert(_start < _end)
- byte b = _bytes[_start];
- if ((b >= 0) && (++_start < _end)) {
- cbuf[i++] = (char) b; // Most common case.
- } else if (b < 0) {
- if (i < off_plus_len - 1) { // Up to two 'char' can be read.
- int code = read2();
- if (code < 0x10000) {
- cbuf[i++] = (char) code;
- } else if (code <= 0x10ffff) { // Surrogates.
- cbuf[i++] = (char) (((code - 0x10000) >> 10) + 0xd800);
- cbuf[i++] = (char) (((code - 0x10000) & 0x3ff) + 0xdc00);
- } else {
- throw new CharConversionException("Cannot convert U+"
- + Integer.toHexString(code)
- + " to char (code greater than U+10FFFF)");
- }
- if (_start < _end) {
- continue;
- }
- }
- return i - off;
- } else { // End of buffer (_start >= _end).
- cbuf[i++] = (char) b;
- return i - off;
- }
- }
- return len;
- }
-
- /**
- * Reads characters into the specified appendable. This method will block
- * until the end of the stream is reached.
- *
- * @param dest the destination buffer.
- * @throws IOException if an I/O error occurs.
- */
- public void read(Appendable dest) throws IOException {
- if (_inputStream == null)
- throw new IOException("No input stream or stream closed");
- while (true) {
- if (_start >= _end) { // Fills buffer.
- _start = 0;
- _end = _inputStream.read(_bytes, 0, _bytes.length);
- if (_end <= 0) { // Done.
- break;
- }
- }
- byte b = _bytes[_start];
- if (b >= 0) {
- dest.append((char) b); // Most common case.
- _start++;
- } else {
- int code = read2();
- if (code < 0x10000) {
- dest.append((char) code);
- } else if (code <= 0x10ffff) { // Surrogates.
- dest.append((char) (((code - 0x10000) >> 10) + 0xd800));
- dest.append((char) (((code - 0x10000) & 0x3ff) + 0xdc00));
- } else {
- throw new CharConversionException("Cannot convert U+"
- + Integer.toHexString(code)
- + " to char (code greater than U+10FFFF)");
- }
- }
- }
- }
-
- public void reset() {
- _code = 0;
- _end = 0;
- _inputStream = null;
- _moreBytes = 0;
- _start = 0;
- }
-
- /**
- * @deprecated Replaced by {@link #setInput(InputStream)}
- */
- public UTF8StreamReader setInputStream(InputStream inStream) {
- return this.setInput(inStream);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8StreamWriter.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8StreamWriter.java b/commons/marmotta-commons/src/ext/java/javolution/io/UTF8StreamWriter.java
deleted file mode 100644
index a5872e3..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/io/UTF8StreamWriter.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.io;
-
-import java.io.CharConversionException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-
-/**
- * <p> A UTF-8 stream writer.</p>
- *
- * <p> This writer supports surrogate <code>char</code> pairs (representing
- * characters in the range [U+10000 .. U+10FFFF]). It can also be used
- * to write characters from their unicodes (31 bits) directly
- * (ref. {@link #write(int)}).</p>
- *
- * <p> Instances of this class can be reused for different output streams
- * and can be part of a higher level component (e.g. serializer) in order
- * to avoid dynamic buffer allocation when the destination output changes.
- * Also wrapping using a <code>java.io.BufferedWriter</code> is unnescessary
- * as instances of this class embed their own data buffers.</p>
- *
- * <p> Note: This writer is unsynchronized and always produces well-formed
- * UTF-8 sequences.</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 2.0, December 9, 2004
- */
-public final class UTF8StreamWriter extends Writer {
-
- /**
- * Holds the current output stream or <code>null</code> if closed.
- */
- private OutputStream _outputStream;
-
- /**
- * Holds the bytes' buffer.
- */
- private final byte[] _bytes;
-
- /**
- * Holds the bytes buffer index.
- */
- private int _index;
-
- /**
- * Creates a UTF-8 writer having a byte buffer of moderate capacity (2048).
- */
- public UTF8StreamWriter() {
- _bytes = new byte[2048];
- }
-
- /**
- * Creates a UTF-8 writer having a byte buffer of specified capacity.
- *
- * @param capacity the capacity of the byte buffer.
- */
- public UTF8StreamWriter(int capacity) {
- _bytes = new byte[capacity];
- }
-
- /**
- * Sets the output stream to use for writing until this writer is closed.
- * For example:[code]
- * Writer writer = new UTF8StreamWriter().setOutputStream(out);
- * [/code] is equivalent but writes faster than [code]
- * Writer writer = new java.io.OutputStreamWriter(out, "UTF-8");
- * [/code]
- *
- * @param out the output stream.
- * @return this UTF-8 writer.
- * @throws IllegalStateException if this writer is being reused and
- * it has not been {@link #close closed} or {@link #reset reset}.
- */
- public UTF8StreamWriter setOutput(OutputStream out) {
- if (_outputStream != null)
- throw new IllegalStateException("Writer not closed or reset");
- _outputStream = out;
- return this;
- }
-
- /**
- * Writes a single character. This method supports 16-bits
- * character surrogates.
- *
- * @param c <code>char</code> the character to be written (possibly
- * a surrogate).
- * @throws IOException if an I/O error occurs.
- */
- public void write(char c) throws IOException {
- if ((c < 0xd800) || (c > 0xdfff)) {
- write((int) c);
- } else if (c < 0xdc00) { // High surrogate.
- _highSurrogate = c;
- } else { // Low surrogate.
- int code = ((_highSurrogate - 0xd800) << 10) + (c - 0xdc00)
- + 0x10000;
- write(code);
- }
- }
-
- private char _highSurrogate;
-
- /**
- * Writes a character given its 31-bits Unicode.
- *
- * @param code the 31 bits Unicode of the character to be written.
- * @throws IOException if an I/O error occurs.
- */
- public void write(int code) throws IOException {
- if ((code & 0xffffff80) == 0) {
- _bytes[_index] = (byte) code;
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else { // Writes more than one byte.
- write2(code);
- }
- }
-
- private void write2(int c) throws IOException {
- if ((c & 0xfffff800) == 0) { // 2 bytes.
- _bytes[_index] = (byte) (0xc0 | (c >> 6));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | (c & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else if ((c & 0xffff0000) == 0) { // 3 bytes.
- _bytes[_index] = (byte) (0xe0 | (c >> 12));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 6) & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | (c & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else if ((c & 0xff200000) == 0) { // 4 bytes.
- _bytes[_index] = (byte) (0xf0 | (c >> 18));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 12) & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 6) & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | (c & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else if ((c & 0xf4000000) == 0) { // 5 bytes.
- _bytes[_index] = (byte) (0xf8 | (c >> 24));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 18) & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 12) & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 6) & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | (c & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else if ((c & 0x80000000) == 0) { // 6 bytes.
- _bytes[_index] = (byte) (0xfc | (c >> 30));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 24) & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 18) & 0x3f));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 12) & 0x3F));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | ((c >> 6) & 0x3F));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- _bytes[_index] = (byte) (0x80 | (c & 0x3F));
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else {
- throw new CharConversionException("Illegal character U+"
- + Integer.toHexString(c));
- }
- }
-
- /**
- * Writes a portion of an array of characters.
- *
- * @param cbuf the array of characters.
- * @param off the offset from which to start writing characters.
- * @param len the number of characters to write.
- * @throws IOException if an I/O error occurs.
- */
- public void write(char cbuf[], int off, int len) throws IOException {
- final int off_plus_len = off + len;
- for (int i = off; i < off_plus_len;) {
- char c = cbuf[i++];
- if (c < 0x80) {
- _bytes[_index] = (byte) c;
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else {
- write(c);
- }
- }
- }
-
- /**
- * Writes a portion of a string.
- *
- * @param str a String.
- * @param off the offset from which to start writing characters.
- * @param len the number of characters to write.
- * @throws IOException if an I/O error occurs
- */
- public void write(String str, int off, int len) throws IOException {
- final int off_plus_len = off + len;
- for (int i = off; i < off_plus_len;) {
- char c = str.charAt(i++);
- if (c < 0x80) {
- _bytes[_index] = (byte) c;
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else {
- write(c);
- }
- }
- }
-
- /**
- * Writes the specified character sequence.
- *
- * @param csq the character sequence.
- * @throws IOException if an I/O error occurs
- */
- public void write(CharSequence csq) throws IOException {
- final int length = csq.length();
- for (int i = 0; i < length;) {
- char c = csq.charAt(i++);
- if (c < 0x80) {
- _bytes[_index] = (byte) c;
- if (++_index >= _bytes.length) {
- flushBuffer();
- }
- } else {
- write(c);
- }
- }
- }
-
- /**
- * Flushes the stream. If the stream has saved any characters from the
- * various write() methods in a buffer, write them immediately to their
- * intended destination. Then, if that destination is another character or
- * byte stream, flush it. Thus one flush() invocation will flush all the
- * buffers in a chain of Writers and OutputStreams.
- *
- * @throws IOException if an I/O error occurs.
- */
- public void flush() throws IOException {
- flushBuffer();
- _outputStream.flush();
- }
-
- /**
- * Closes and {@link #reset resets} this writer for reuse.
- *
- * @throws IOException if an I/O error occurs
- */
- public void close() throws IOException {
- if (_outputStream != null) {
- flushBuffer();
- _outputStream.close();
- reset();
- }
- }
-
- /**
- * Flushes the internal bytes buffer.
- *
- * @throws IOException if an I/O error occurs
- */
- private void flushBuffer() throws IOException {
- if (_outputStream == null)
- throw new IOException("Stream closed");
- _outputStream.write(_bytes, 0, _index);
- _index = 0;
- }
-
- public void reset() {
- _highSurrogate = 0;
- _index = 0;
- _outputStream = null;
- }
-
- /**
- * @deprecated Replaced by {@link #setOutput(OutputStream)}
- */
- public UTF8StreamWriter setOutputStream(OutputStream out) {
- return this.setOutput(out);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/io/Union.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/io/Union.java b/commons/marmotta-commons/src/ext/java/javolution/io/Union.java
deleted file mode 100644
index e8ae270..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/io/Union.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.io;
-
-/**
- * <p> Equivalent to <code>C/C++ union</code>; this class works in the same
- * way as {@link Struct} (sub-class) except that all members are mapped
- * to the same location in memory.</p>
- * <p> Here is an example of C union:
- * [code]
- * union Number {
- * int asInt;
- * float asFloat;
- * char asString[12];
- * };[/code]</p>
- * <p> And its Java equivalent:
- * [code]
- * public class Number extends Union {
- * Signed32 asInt = new Signed32();
- * Float32 asFloat = new Float32();
- * Utf8String asString = new Utf8String(12);
- * }[/code]</p>
- * <p> As for any {@link Struct}, fields are directly accessible:
- * [code]
- * Number num = new Number();
- * num.asInt.set(23);
- * num.asString.set("23"); // Null terminated (C compatible)
- * float f = num.asFloat.get();[/code]</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 1.0, October 4, 2004
- */
-public abstract class Union extends Struct {
-
- /**
- * Default constructor.
- */
- public Union() {}
-
- /**
- * Returns <code>true</code>.
- *
- * @return <code>true</code>
- */
- public final boolean isUnion() {
- return true;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/io/package-info.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/io/package-info.java b/commons/marmotta-commons/src/ext/java/javolution/io/package-info.java
deleted file mode 100644
index 6e000ae..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/io/package-info.java
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
-<p> Utility classes for input and output such as
- {@link javolution.io.Struct Struct} and {@link javolution.io.Union Union}
- for direct interoperability with C/C++.</p>
- */
-package javolution.io;
-
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/lang/Configurable.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/lang/Configurable.java b/commons/marmotta-commons/src/ext/java/javolution/lang/Configurable.java
deleted file mode 100644
index 394c60e..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/lang/Configurable.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.lang;
-
-import java.lang.reflect.Field;
-
-import javolution.context.LogContext;
-import javolution.context.SecurityContext;
-import javolution.context.SecurityContext.Permission;
-import javolution.osgi.internal.OSGiServices;
-import javolution.text.DefaultTextFormat;
-import javolution.text.TextContext;
-
-/**
- * <p> An element which is configurable without presupposing how the
- * configuration is done.</p>
- *
- * <p> Does your class need to know or has to assume that the configuration is
- * coming from system properties ??</p>
- *
- * <p> The response is obviously NO !</p>
- *
- * <p> Let's compare the following examples:
- * [code]
- * class Document {
- * private static final Font FONT
- * = Font.decode(System.getProperty("pkg.Document#FONT") != null ?
- * System.getProperty("FONT") : "Arial-BOLD-18");
- * }[/code]</p>
- *
- * <p>With the following:
- * [code]
- * class Document {
- * public static final Configurable<Font> FONT = new Configurable<Font>() {
- * @Override
- * protected Font getDefault() {
- * new Font("Arial", Font.BOLD, 18);
- * }
- * };
- * }[/code]</p>
- *
- * <p> Not only the second example is cleaner, but the actual configuration
- * data can come from anywhere, from system properties (default),
- * OSGi Configuration Admin service, another bundle, etc.
- * Low level code does not need to know.</p>
- *
- * <p> Configurables may perform any logic upon initialization or
- * update. Users are notified of configuration events through
- * the OSGi {@link Configurable.Listener} service.
- * [code]
- * class Index {
- * // Holds the number of unique preallocated instances (default {@code 1024}).
- * public static final Configurable<Integer> UNIQUE = new Configurable<Integer>() {
- * @Override
- * protected Integer getDefault() {
- * return 1024;
- * }
- * @Override
- * protected Integer initialized(Integer value) {
- * return MathLib.min(value, 65536); // Hard-limiting
- * }
- * @Override
- * protected Integer reconfigured(Integer oldCount, Integer newCount) {
- * throw new UnsupportedOperationException("Unicity reconfiguration not supported.");
- * }
- * }
- * }[/code]</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 6.0, July 21, 2013
- */
-public abstract class Configurable<T> {
-
- /**
- * Services to be published by any one interested in being informed of
- * configurable changes.
- */
- public interface Listener {
-
- /**
- * Receives notification that a configurable has been initialized..
- *
- * @param configurable the configurable instance being initialized.
- * @param value the initial value.
- */
- <T> void configurableInitialized(Configurable<T> configurable, T value);
-
- /**
- * Receives notification that a configurable has been updated.
- *
- * @param configurable the configurable instance being updated.
- * @param oldValue the previous value.
- * @param newValue the updated value.
- */
- <T> void configurableReconfigured(Configurable<T> configurable,
- T oldValue, T newValue);
-
- }
-
- /**
- * Holds the general permission to reconfigure configurable instances
- * (action <code>"reconfigure"</code>).
- * Whether or not that permission is granted depends on the current
- * {@link SecurityContext}. It is possible that the general permission
- * to reconfigure a configurable is granted but revoked for a specific
- * instance. Also, the general permission to reconfigure a configurable
- * may be revoked but granted only for a specific instance.
- */
- public static Permission<Configurable<?>> RECONFIGURE_PERMISSION = new Permission<Configurable<?>>(
- Configurable.class, "reconfigure");
-
- /**
- * Holds the configurable name.
- */
- private String name;
-
- /**
- * Holds the reconfigure permission.
- */
- private final Permission<Configurable<T>> reconfigurePermission;
-
- /**
- * Holds the configurable value.
- */
- private volatile T value;
-
- /**
- * Creates a new configurable. If a system property exist for this
- * configurable's {@link #getName() name}, then
- * the {@link #parse parsed} value of the property supersedes the
- * {@link #getDefault() default} value of this configurable.
- * For example, running the JVM with
- * the option {@code -Djavolution.context.ConcurrentContext#CONCURRENCY=0}
- * disables concurrency support.
- */
- public Configurable() {
- reconfigurePermission = new Permission<Configurable<T>>(
- Configurable.class, "reconfigure", this);
- String name = getName();
- T defaultValue = getDefault();
- if (name != null) {
- try { // Checks system properties.
- String property = System.getProperty(name);
- if (property != null) {
- defaultValue = parse(property); // Supersedes.
- LogContext.debug(name, ", System Properties Value: ",
- defaultValue);
- }
- } catch (SecurityException securityError) {
- // Ok, current runtime does not allow system properties access.
- }
- }
- this.name = name;
- this.value = initialized(defaultValue);
- Object[] listeners = OSGiServices.getConfigurableListeners();
- for (Object listener : listeners) {
- ((Listener) listener).configurableInitialized(this, this.value);
- }
- }
-
- /**
- * Returns this configurable value.
- */
- public T get() {
- return value;
- }
-
- /**
- * Returns this configurable name. By convention, the name of the
- * configurable is the name of the static field holding the
- * configurable (e.g. "javolution.context.ConcurrentContext#CONCURRENCY").
- * This method should be overridden if the enclosing class needs to be
- * impervious to obfuscation or if the enclosing class defines multiple
- * configurable fields.
- *
- * @throws UnsupportedOperationException if the enclosing class has
- * multiple configurable static fields.
- */
- public String getName() {
- if (name != null)
- return name; // Already set.
- Class<?> thisClass = this.getClass();
- Class<?> enclosingClass = thisClass.getEnclosingClass();
- String fieldName = null;
- for (Field field : enclosingClass.getFields()) {
- if (field.getType().isAssignableFrom(thisClass)) {
- if (fieldName != null) // Indistinguishable field types.
- throw new UnsupportedOperationException(
- "Multiple configurables static fields in the same class" +
- "requires the Configurable.getName() method to be overriden.");
- fieldName = field.getName();
- }
- }
- return (fieldName != null) ? enclosingClass.getName() + "#" + fieldName
- : null;
- }
-
- /**
- * Returns the permission to configure this instance.
- */
- public Permission<Configurable<T>> getReconfigurePermission() {
- return reconfigurePermission;
- }
-
- /**
- * Reconfigures this instance with the specified value if authorized
- * by the {@link SecurityContext}. This method returns the actual new
- * value which may be different from the requested new value
- * (see {@link #reconfigured(Object, Object)}).
- *
- * @param newValue the requested new value.
- * @return the actual new value.
- * @throws SecurityException if the permission to reconfigure this
- * configurable is not granted.
- * @throws UnsupportedOperationException if this configurable does not
- * support dynamic reconfiguration.
- */
- public T reconfigure(T newValue) {
- SecurityContext.check(reconfigurePermission);
- synchronized (this) {
- T oldValue = this.value;
- this.value = reconfigured(oldValue, newValue);
- Object[] listeners = OSGiServices.getConfigurableListeners();
- for (Object listener : listeners) {
- ((Listener) listener).configurableReconfigured(this, oldValue,
- this.value);
- }
- return this.value;
- }
- }
-
- /**
- * Returns this configurable default value (always different from
- * {@code null}).
- */
- protected abstract T getDefault();
-
- /**
- * This methods is called when the configurable is initialized.
- * Developers may override this method to perform
- * any initialization logic (e.g. input validation).
- *
- * @param value the requested value for this configurable.
- * @return the actual value of this configurable.
- */
- protected T initialized(T value) {
- return value;
- }
-
- /**
- * Parses the specified text to return the corresponding value.
- * This method is used to initialize this configurable from
- * system properties. The default implementation uses the
- * {@link TextContext} to retrieve the text format
- * (based on the {@link DefaultTextFormat} class annotation).
- */
- @SuppressWarnings("unchecked")
- protected T parse(String str) {
- Class<? extends T> type = (Class<? extends T>) getDefault().getClass();
- return TextContext.getFormat(type).parse(str);
- }
-
- /**
- * This methods is called when the configurable is reconfigured.
- * Developers may override this method to perform
- * any reconfiguration logic (e.g. hard limiting values).
- *
- * @param oldValue the old value.
- * @param newValue the requested new value.
- * @return the actual new value of this configurable.
- * @throws UnsupportedOperationException if this configurable does not
- * support dynamic reconfiguration.
- */
- protected T reconfigured(T oldValue, T newValue) {
- return newValue;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/lang/Initializer.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/lang/Initializer.java b/commons/marmotta-commons/src/ext/java/javolution/lang/Initializer.java
deleted file mode 100644
index 81f2823..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/lang/Initializer.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.lang;
-
-import java.util.Vector;
-import javolution.context.LogContext;
-
-/**
- * <p> An initializer for all classes loaded by any given class loader.</p>
- *
- * <p> Initialization of classes at startup (or during bundle activation)
- * ensures a significantly improved worst case execution time especially
- * if the classes has {@link Configurable configuration logic} to be
- * executed then.</p>
- *
- * <p> Javolution activator initialize {@link Realtime} classes when started.
- * When running outside OSGi the method
- * {@code javolution.osgi.internal.OSGiServices.initializeRealtimeClasses()}
- * can be used to that effect..</p>
- *
- * <p> Class loading can be performed in a lazy manner and therefore some parts
- * of the class loading process may be done on first use rather than at
- * load time. Javolution bundle activator ensure that <b>all</b> its classes
- * are initialized at start up.
- * The following code illustrates how this can be done for any bundle.
- * [code]
- * public class MyActivator implements BundleActivator {
- * public void start(BundleContext bc) throws Exception {
- * Initializer initializer = new Initializer(MyActivator.class.getClassLoader());
- * initializer.loadClass(com.foo.internal.UnreferencedClass.class);
- * // Load explicitly classes not directly or indirectly referenced.
- * ...
- * initializer.initializeLoadedClasses(); // Recursive loading/initialization.
- * ... // Continue activation
- * }
- * }[/code]</p>
- *
- * <p> This utility use reflection to find the classes loaded and may not be
- * supported on all platforms.</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 5.1, July 26, 2007
- */
-public class Initializer {
-
- /**
- * Indicates if the class being initialized should be logged
- * (default {@code false}).
- */
- public static final Configurable<Boolean> SHOW_INITIALIZED = new Configurable<Boolean>() {
- @Override
- protected Boolean getDefault() {
- return false;
- }
- };
-
- /** The class loader for this initializer */
- private final ClassLoader classLoader;
-
- /**
- * Creates an initializer for the specified class loader.
- */
- public Initializer(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- /**
- * Returns the classes loaded by the class loader of this initializer or
- * <code>null</code> if not supported by the platform.
- */
- @SuppressWarnings("unchecked")
- public Class<?>[] loadedClasses() {
- Class<?> cls = classLoader.getClass();
- while (cls != java.lang.ClassLoader.class) {
- cls = cls.getSuperclass();
- }
- try {
- java.lang.reflect.Field fldClasses = cls
- .getDeclaredField("classes");
- fldClasses.setAccessible(true);
- Vector<Class<?>> list = (Vector<Class<?>>) fldClasses
- .get(classLoader);
- Class<?>[] classes = new Class<?>[list.size()];
- for (int i = 0; i < classes.length; i++) {
- classes[i] = list.get(i);
- }
- return classes;
- } catch (Throwable e) {
- return null;
- }
- }
-
- /**
- * Loads the specified class (does not perform any initialization).
- * This method is typically used to load unreferenced classes.
- */
- public void loadClass(Class<?> cls) {
- try {
- classLoader.loadClass(cls.getName());
- } catch (ClassNotFoundException e) {
- LogContext.debug("Class " + cls + " not found.");
- }
- }
-
- /**
- * Initializes all the loaded classes. If the initialization leads to more
- * classes being loaded, these classes are initialized as well
- * (recursive process).
- *
- * @return {@code true} if initialization has been performed successfully;
- * {@code false} otherwise.
- */
- public boolean initializeLoadedClasses() {
- boolean isInitializationSuccessful = true;
- int nbrClassesInitialized = 0;
- while (true) {
- Class<?>[] classes = loadedClasses();
- if (classes == null) {
- LogContext
- .debug("Automatic class initialization not supported.");
- return false;
- }
- if (nbrClassesInitialized >= classes.length)
- break; // Done.
- for (int i = nbrClassesInitialized; i < classes.length; i++) {
- Class<?> cls = classes[i];
- try {
- if (SHOW_INITIALIZED.get())
- LogContext.debug("Initialize ", cls.getName());
- Class.forName(cls.getName(), true, classLoader);
- } catch (ClassNotFoundException ex) {
- isInitializationSuccessful = false;
- LogContext.error(ex); // Should never happen.
- }
- }
- nbrClassesInitialized = classes.length;
- }
- LogContext.debug("Initialization of ", nbrClassesInitialized,
- " classes loaded by ", classLoader);
- return isInitializationSuccessful;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/lang/Parallelizable.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/lang/Parallelizable.java b/commons/marmotta-commons/src/ext/java/javolution/lang/Parallelizable.java
index 5238c1d..0c1001a 100644
--- a/commons/marmotta-commons/src/ext/java/javolution/lang/Parallelizable.java
+++ b/commons/marmotta-commons/src/ext/java/javolution/lang/Parallelizable.java
@@ -8,12 +8,7 @@
*/
package javolution.lang;
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.*;
/**
* <p> Indicates that a class, a method or a field can be used by multiple
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/lang/Realtime.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/lang/Realtime.java b/commons/marmotta-commons/src/ext/java/javolution/lang/Realtime.java
index 2757ad3..0b7a24a 100644
--- a/commons/marmotta-commons/src/ext/java/javolution/lang/Realtime.java
+++ b/commons/marmotta-commons/src/ext/java/javolution/lang/Realtime.java
@@ -8,12 +8,7 @@
*/
package javolution.lang;
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.*;
/**
* <p> Indicates if an element has a bounded
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/ConfigurableListenerImpl.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/ConfigurableListenerImpl.java b/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/ConfigurableListenerImpl.java
deleted file mode 100644
index 8983824..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/ConfigurableListenerImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.osgi.internal;
-
-import javolution.context.LogContext;
-import javolution.lang.Configurable;
-
-/**
- * Holds the default implementation of Configurable.Listener when running
- * outside OSGi (logs configuration events).
- */
-public final class ConfigurableListenerImpl implements Configurable.Listener {
-
- @Override
- public <T> void configurableInitialized(Configurable<T> configurable,
- T value) {
- LogContext.debug(configurable.getName(), "=", value);
- }
-
- @Override
- public <T> void configurableReconfigured(Configurable<T> configurable,
- T oldValue, T newValue) {
- LogContext.debug(configurable.getName(),
- " reconfigured from ", oldValue, " to ", newValue);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/JavolutionActivator.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/JavolutionActivator.java b/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/JavolutionActivator.java
deleted file mode 100644
index a4b1c6d..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/JavolutionActivator.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.osgi.internal;
-
-import javolution.xml.stream.XMLInputFactory;
-import javolution.xml.stream.XMLOutputFactory;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * Javolution OSGi bundle activator.
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 6.0, July 21, 2013
- */
-public class JavolutionActivator implements BundleActivator {
-
- // Services provided by Javolution.
- private ServiceRegistration<XMLInputFactory> xmlInputFactoryRegistration;
- private ServiceRegistration<XMLOutputFactory> xmlOutputFactoryRegistration;
-
- @SuppressWarnings("unchecked")
- public void start(BundleContext bc) throws Exception {
-
- // Activate services trackers.
- OSGiServices.CONCURRENT_CONTEXT_TRACKER.activate(bc);
- OSGiServices.CONFIGURABLE_LISTENER_TRACKER.activate(bc);
- OSGiServices.LOCAL_CONTEXT_TRACKER.activate(bc);
- OSGiServices.LOG_CONTEXT_TRACKER.activate(bc);
- OSGiServices.LOG_SERVICE_TRACKER.activate(bc);
- OSGiServices.SECURITY_CONTEXT_TRACKER.activate(bc);
- OSGiServices.STORAGE_CONTEXT_TRACKER.activate(bc);
- OSGiServices.TEXT_CONTEXT_TRACKER.activate(bc);
- OSGiServices.XML_CONTEXT_TRACKER.activate(bc);
- OSGiServices.XML_INPUT_FACTORY_TRACKER.activate(bc);
- OSGiServices.XML_OUTPUT_FACTORY_TRACKER.activate(bc);
-
- // Publish XMLInputFactory/XMLOutputFactory services.
- xmlInputFactoryRegistration = (ServiceRegistration<XMLInputFactory>) bc
- .registerService(XMLInputFactory.class.getName(),
- new XMLInputFactoryProvider(), null);
- xmlOutputFactoryRegistration = (ServiceRegistration<XMLOutputFactory>) bc
- .registerService(XMLOutputFactory.class.getName(),
- new XMLOutputFactoryProvider(), null);
-
- // Ensures low latency for real-time classes.
- OSGiServices.initializeRealtimeClasses();
- }
-
- public void stop(BundleContext bc) throws Exception {
- OSGiServices.CONCURRENT_CONTEXT_TRACKER.deactivate(bc);
- OSGiServices.CONFIGURABLE_LISTENER_TRACKER.deactivate(bc);
- OSGiServices.LOCAL_CONTEXT_TRACKER.deactivate(bc);
- OSGiServices.LOG_CONTEXT_TRACKER.deactivate(bc);
- OSGiServices.LOG_SERVICE_TRACKER.deactivate(bc);
- OSGiServices.SECURITY_CONTEXT_TRACKER.deactivate(bc);
- OSGiServices.STORAGE_CONTEXT_TRACKER.deactivate(bc);
- OSGiServices.TEXT_CONTEXT_TRACKER.deactivate(bc);
- OSGiServices.XML_CONTEXT_TRACKER.deactivate(bc);
- OSGiServices.XML_INPUT_FACTORY_TRACKER.deactivate(bc);
- OSGiServices.XML_OUTPUT_FACTORY_TRACKER.deactivate(bc);
-
- xmlInputFactoryRegistration.unregister();
- xmlOutputFactoryRegistration.unregister();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/LogServiceImpl.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/LogServiceImpl.java b/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/LogServiceImpl.java
deleted file mode 100644
index 8fa4ece..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/LogServiceImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.osgi.internal;
-
-import javolution.util.FastTable;
-
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * Holds the default implementation of LogService to be used when running
- * outside OSGi or when the Javolution bundle is not started.
- */
-public final class LogServiceImpl extends Thread implements LogService {
-
- private static class LogEvent {
- Throwable exception;
- int level;
- String message;
- }
-
- private final FastTable<LogEvent> eventQueue = new FastTable<LogEvent>();
-
- public LogServiceImpl() {
- super("Logging-Thread");
- setDaemon(true);
- this.start();
- Thread hook = new Thread(new Runnable() {
- @Override
- public void run() { // Maintains the VM alive until the event queue is flushed
- synchronized (eventQueue) {
- try {
- while (!eventQueue.isEmpty())
- eventQueue.wait();
- } catch (InterruptedException e) {}
- }
- }
- });
- Runtime.getRuntime().addShutdownHook(hook);
- }
-
- @Override
- public void log(int level, String message) {
- log(level, message, null);
- }
-
- @Override
- public void log(int level, String message, Throwable exception) {
- LogEvent event = new LogEvent();
- event.level = level;
- event.message = message;
- event.exception = exception;
- synchronized (eventQueue) {
- eventQueue.addFirst(event);
- eventQueue.notify();
- }
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public void log(ServiceReference sr, int level, String message) {
- throw new UnsupportedOperationException();
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public void log(ServiceReference sr, int level, String message,
- Throwable exception) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void run() {
- while (true) {
- try {
- LogEvent event;
- synchronized (eventQueue) {
- while (eventQueue.isEmpty())
- eventQueue.wait();
- event = eventQueue.pollLast();
- eventQueue.notify();
- }
- switch (event.level) {
- case LogService.LOG_DEBUG:
- System.out.println("[DEBUG] " + event.message);
- break;
- case LogService.LOG_INFO:
- System.out.println("[INFO] " + event.message);
- break;
- case LogService.LOG_WARNING:
- System.out.println("[WARNING] " + event.message);
- break;
- case LogService.LOG_ERROR:
- System.out.println("[ERROR] " + event.message);
- break;
- default:
- System.out.println("[UNKNOWN] " + event.message);
- break;
- }
- if (event.exception != null) {
- event.exception.printStackTrace(System.out);
- }
- } catch (InterruptedException error) {
- error.printStackTrace(System.err);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/OSGiServices.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/OSGiServices.java b/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/OSGiServices.java
deleted file mode 100644
index 5c35abe..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/OSGiServices.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.osgi.internal;
-
-import javolution.context.ConcurrentContext;
-import javolution.context.LocalContext;
-import javolution.context.LogContext;
-import javolution.context.SecurityContext;
-import javolution.context.StorageContext;
-import javolution.context.internal.ConcurrentContextImpl;
-import javolution.context.internal.LocalContextImpl;
-import javolution.context.internal.LogContextImpl;
-import javolution.context.internal.SecurityContextImpl;
-import javolution.context.internal.StorageContextImpl;
-import javolution.io.Struct;
-import javolution.lang.Configurable;
-import javolution.lang.Initializer;
-import javolution.lang.MathLib;
-import javolution.text.Text;
-import javolution.text.TextContext;
-import javolution.text.TypeFormat;
-import javolution.text.internal.TextContextImpl;
-import javolution.util.FastBitSet;
-import javolution.util.FastSortedMap;
-import javolution.util.FastSortedSet;
-import javolution.util.FastSortedTable;
-import javolution.util.Index;
-import javolution.util.function.Equalities;
-import javolution.util.function.Reducers;
-import javolution.xml.XMLContext;
-import javolution.xml.internal.XMLContextImpl;
-import javolution.xml.internal.stream.XMLInputFactoryImpl;
-import javolution.xml.internal.stream.XMLOutputFactoryImpl;
-import javolution.xml.internal.stream.XMLStreamReaderImpl;
-import javolution.xml.internal.stream.XMLStreamWriterImpl;
-import javolution.xml.stream.XMLInputFactory;
-import javolution.xml.stream.XMLOutputFactory;
-
-import org.osgi.service.log.LogService;
-
-/**
- * The OSGi services tracked by the Javolution bundle.
- * When running outside OSGi or when the Javolution bundle is not started
- * the default service implementation is returned.
- */
-public class OSGiServices {
-
- final static ServiceTrackerImpl<ConcurrentContext> CONCURRENT_CONTEXT_TRACKER = new ServiceTrackerImpl<ConcurrentContext>(
- ConcurrentContext.class, ConcurrentContextImpl.class);
- final static ServiceTrackerImpl<Configurable.Listener> CONFIGURABLE_LISTENER_TRACKER = new ServiceTrackerImpl<Configurable.Listener>(
- Configurable.Listener.class, ConfigurableListenerImpl.class);
- final static ServiceTrackerImpl<LocalContext> LOCAL_CONTEXT_TRACKER = new ServiceTrackerImpl<LocalContext>(
- LocalContext.class, LocalContextImpl.class);
- final static ServiceTrackerImpl<LogContext> LOG_CONTEXT_TRACKER = new ServiceTrackerImpl<LogContext>(
- LogContext.class, LogContextImpl.class);
- final static ServiceTrackerImpl<LogService> LOG_SERVICE_TRACKER = new ServiceTrackerImpl<LogService>(
- LogService.class, LogServiceImpl.class);
- final static ServiceTrackerImpl<SecurityContext> SECURITY_CONTEXT_TRACKER = new ServiceTrackerImpl<SecurityContext>(
- SecurityContext.class, SecurityContextImpl.class);
- final static ServiceTrackerImpl<StorageContext> STORAGE_CONTEXT_TRACKER = new ServiceTrackerImpl<StorageContext>(
- StorageContext.class, StorageContextImpl.class);
- final static ServiceTrackerImpl<TextContext> TEXT_CONTEXT_TRACKER = new ServiceTrackerImpl<TextContext>(
- TextContext.class, TextContextImpl.class);
- final static ServiceTrackerImpl<XMLContext> XML_CONTEXT_TRACKER = new ServiceTrackerImpl<XMLContext>(
- XMLContext.class, XMLContextImpl.class);
- final static ServiceTrackerImpl<XMLInputFactory> XML_INPUT_FACTORY_TRACKER = new ServiceTrackerImpl<XMLInputFactory>(
- XMLInputFactory.class, XMLInputFactoryImpl.class);
- final static ServiceTrackerImpl<XMLOutputFactory> XML_OUTPUT_FACTORY_TRACKER = new ServiceTrackerImpl<XMLOutputFactory>(
- XMLOutputFactory.class, XMLOutputFactoryImpl.class);
-
- /** Returns concurrent context services. */
- public static ConcurrentContext getConcurrentContext() {
- return (ConcurrentContext)CONCURRENT_CONTEXT_TRACKER.getServices()[0];
- }
-
- /** Returns configurable listener services. */
- public static Object[] getConfigurableListeners() {
- return CONFIGURABLE_LISTENER_TRACKER.getServices();
- }
-
- /** Returns local context service. */
- public static LocalContext getLocalContext() {
- return (LocalContext)LOCAL_CONTEXT_TRACKER.getServices()[0];
- }
-
- /** Returns log context service. */
- public static LogContext getLogContext() {
- return (LogContext)LOG_CONTEXT_TRACKER.getServices()[0];
- }
-
- /** Returns OSGi log service. */
- public static Object[] getLogServices() {
- return LOG_SERVICE_TRACKER.getServices();
- }
-
- /** Returns security context service. */
- public static SecurityContext getSecurityContext() {
- return (SecurityContext) SECURITY_CONTEXT_TRACKER.getServices()[0];
- }
-
- /** Returns storage context service. */
- public static StorageContext getStorageContext() {
- return (StorageContext) STORAGE_CONTEXT_TRACKER.getServices()[0];
- }
-
- /** Returns text context service. */
- public static TextContext getTextContext() {
- return (TextContext)TEXT_CONTEXT_TRACKER.getServices()[0];
- }
-
- /** Returns xml context service. */
- public static XMLContext getXMLContext() {
- return (XMLContext)XML_CONTEXT_TRACKER.getServices()[0];
- }
-
- /** Returns xml input factory service. */
- public static XMLInputFactory getXMLInputFactory() {
- return (XMLInputFactory)XML_INPUT_FACTORY_TRACKER.getServices()[0];
- }
-
- /** Returns xml output factory service. */
- public static XMLOutputFactory getXMLOutputFactory() {
- return (XMLOutputFactory)XML_OUTPUT_FACTORY_TRACKER.getServices()[0];
- }
-
- /** Initializes all real-time classes. */
- public static boolean initializeRealtimeClasses() {
- Initializer initializer = new Initializer(OSGiServices.class.getClassLoader());
- initializer.loadClass(MathLib.class);
- initializer.loadClass(Text.class);
- initializer.loadClass(TypeFormat.class);
- initializer.loadClass(Struct.class);
- initializer.loadClass(FastBitSet.class);
- initializer.loadClass(FastSortedMap.class);
- initializer.loadClass(FastSortedSet.class);
- initializer.loadClass(FastSortedTable.class);
- initializer.loadClass(Index.class); // Preallocates.
- initializer.loadClass(Reducers.class);
- initializer.loadClass(Equalities.class);
- initializer.loadClass(XMLStreamReaderImpl.class);
- initializer.loadClass(XMLStreamWriterImpl.class);
- return initializer.initializeLoadedClasses();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/ServiceTrackerImpl.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/ServiceTrackerImpl.java b/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/ServiceTrackerImpl.java
deleted file mode 100644
index ac4afdf..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/ServiceTrackerImpl.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.osgi.internal;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Bridge to service tracker (does not trigger class loading exception
- * if running outside OSGi).
- */
-public final class ServiceTrackerImpl<C> {
-
- private volatile ServiceTracker<C, C> tracker;
- private final Class<C> type;
- private final Class<? extends C> defaultImplClass;
- private C defaultImpl;
-
- /** Creates a context tracker for the specified context type. */
- public ServiceTrackerImpl(Class<C> type, Class<? extends C> defaultImplClass) {
- this.defaultImplClass = defaultImplClass;
- this.type = type;
- }
-
- /** Activates OSGi tracking. */
- public void activate(BundleContext bc) {
- ServiceTracker<C, C> trk = new ServiceTracker<C, C>(bc, type, null);
- trk.open();
- tracker = trk;
- }
-
- /** Deactivates OSGi tracking. */
- public void deactivate(BundleContext bc) {
- tracker.close();
- tracker = null;
- }
-
- /** Returns the published services or the default implementation if none. */
- public Object[] getServices() {
- ServiceTracker<C, C> trk = tracker;
- if (trk != null) {
- Object[] services = trk.getServices();
- if (services != null) return services;
- }
- synchronized (this) {
- if (defaultImpl == null) {
- try {
- defaultImpl = defaultImplClass.newInstance();
- } catch (Throwable error) {
- throw new RuntimeException(error);
- }
- }
- }
- return new Object[] { defaultImpl };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/XMLInputFactoryProvider.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/XMLInputFactoryProvider.java b/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/XMLInputFactoryProvider.java
deleted file mode 100644
index e051200..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/XMLInputFactoryProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.osgi.internal;
-
-import javolution.xml.internal.stream.XMLInputFactoryImpl;
-import javolution.xml.stream.XMLInputFactory;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * Holds the service factory providing XMLInputFactory instances.
- */
-public final class XMLInputFactoryProvider implements ServiceFactory<XMLInputFactory> {
-
- @Override
- public XMLInputFactory getService(Bundle bundle,
- ServiceRegistration<XMLInputFactory> registration) {
- return new XMLInputFactoryImpl();
- }
-
- @Override
- public void ungetService(Bundle bundle,
- ServiceRegistration<XMLInputFactory> registration,
- XMLInputFactory service) {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/e60b1a9a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/XMLOutputFactoryProvider.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/XMLOutputFactoryProvider.java b/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/XMLOutputFactoryProvider.java
deleted file mode 100644
index e606805..0000000
--- a/commons/marmotta-commons/src/ext/java/javolution/osgi/internal/XMLOutputFactoryProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
- * Copyright (C) 2012 - Javolution (http://javolution.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package javolution.osgi.internal;
-
-import javolution.xml.internal.stream.XMLOutputFactoryImpl;
-import javolution.xml.stream.XMLOutputFactory;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * Holds the service factory providing XMLInputFactory instances.
- */
-public final class XMLOutputFactoryProvider implements ServiceFactory<XMLOutputFactory> {
-
- @Override
- public XMLOutputFactory getService(Bundle bundle,
- ServiceRegistration<XMLOutputFactory> registration) {
- return new XMLOutputFactoryImpl();
- }
-
- @Override
- public void ungetService(Bundle bundle,
- ServiceRegistration<XMLOutputFactory> registration,
- XMLOutputFactory service) {
- }
-}