Skip to content

Commit

Permalink
Consolidate Utilities (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
fh-ms authored Sep 11, 2023
1 parent 8dccc11 commit 21addff
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.eclipse.serializer.afs.types.AReadableFile;
import org.eclipse.serializer.afs.types.AResolver;
import org.eclipse.serializer.afs.types.AWritableFile;
import org.eclipse.serializer.chars.CharsUtils;
import org.eclipse.serializer.chars.VarString;
import org.eclipse.serializer.chars.XChars;
import org.eclipse.serializer.io.XIO;


Expand Down Expand Up @@ -179,7 +179,7 @@ protected VarString assembleItemPath(
final VarString vs
)
{
return CharsUtils.assembleSeparated(
return XChars.assembleSeparated(
vs,
BlobStorePath.SEPARATOR_CHAR,
item.toPath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import java.util.Arrays;

import org.eclipse.serializer.chars.CharsUtils;
import org.eclipse.serializer.collections.ArraysUtils;
import org.eclipse.serializer.chars.XChars;
import org.eclipse.serializer.collections.XArrays;


public interface BlobStorePath
Expand Down Expand Up @@ -61,7 +61,7 @@ public static String[] splitPath(
final String fullQualifiedPath
)
{
return CharsUtils.splitSimple(fullQualifiedPath, SEPARATOR);
return XChars.splitSimple(fullQualifiedPath, SEPARATOR);
}

public static BlobStorePath New(
Expand Down Expand Up @@ -136,7 +136,7 @@ public BlobStorePath parentPath()
{
return this.pathElements.length > 1
? new BlobStorePath.Default(
ArraysUtils.copyRange(this.pathElements, 0, this.pathElements.length - 1)
XArrays.copyRange(this.pathElements, 0, this.pathElements.length - 1)
)
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.eclipse.serializer.afs.types.AReadableFile;
import org.eclipse.serializer.afs.types.AResolver;
import org.eclipse.serializer.afs.types.AWritableFile;
import org.eclipse.serializer.chars.CharsUtils;
import org.eclipse.serializer.chars.VarString;
import org.eclipse.serializer.chars.XChars;
import org.eclipse.serializer.io.XIO;


Expand Down Expand Up @@ -183,7 +183,7 @@ protected VarString assembleItemPath(
final VarString vs
)
{
return CharsUtils.assembleSeparated(
return XChars.assembleSeparated(
vs,
SqlPath.DIRECTORY_TABLE_NAME_SEPARATOR_CHAR,
item.toPath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import java.util.Arrays;

import org.eclipse.serializer.chars.CharsUtils;
import org.eclipse.serializer.collections.ArraysUtils;
import org.eclipse.serializer.chars.XChars;
import org.eclipse.serializer.collections.XArrays;


public interface SqlPath
Expand All @@ -47,7 +47,7 @@ public static String[] splitPath(
final String fullQualifiedPath
)
{
return CharsUtils.splitSimple(fullQualifiedPath, DIRECTORY_TABLE_NAME_SEPARATOR);
return XChars.splitSimple(fullQualifiedPath, DIRECTORY_TABLE_NAME_SEPARATOR);
}

public static SqlPath New(
Expand Down Expand Up @@ -104,7 +104,7 @@ public SqlPath parentPath()
{
return this.pathElements.length > 1
? new SqlPath.Default(
ArraysUtils.copyRange(this.pathElements, 0, this.pathElements.length - 1)
XArrays.copyRange(this.pathElements, 0, this.pathElements.length - 1)
)
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.nio.file.Files;
import java.nio.file.Path;

import org.eclipse.serializer.chars.CharsUtils;
import org.eclipse.serializer.chars.XChars;
import org.eclipse.serializer.exceptions.IORuntimeException;
import org.eclipse.serializer.util.logging.Logging;
import org.eclipse.store.configuration.exceptions.ConfigurationException;
Expand Down Expand Up @@ -319,7 +319,7 @@ public String loadConfiguration()

try
{
return CharsUtils.readStringFromInputStream(this.inputStream, this.charset);
return XChars.readStringFromInputStream(this.inputStream, this.charset);
}
catch(final IOException e)
{
Expand Down Expand Up @@ -357,7 +357,7 @@ public String loadConfiguration()

try(InputStream in = this.url.openStream())
{
return CharsUtils.readStringFromInputStream(in, this.charset);
return XChars.readStringFromInputStream(in, this.charset);
}
catch(final IOException e)
{
Expand Down Expand Up @@ -395,7 +395,7 @@ public String loadConfiguration()

try(InputStream in = Files.newInputStream(this.path))
{
return CharsUtils.readStringFromInputStream(in, this.charset);
return XChars.readStringFromInputStream(in, this.charset);
}
catch(final IOException e)
{
Expand Down Expand Up @@ -433,7 +433,7 @@ public String loadConfiguration()

try(InputStream in = new FileInputStream(this.file))
{
return CharsUtils.readStringFromInputStream(in, this.charset);
return XChars.readStringFromInputStream(in, this.charset);
}
catch(final IOException e)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
package org.eclipse.store.storage.types;

/*-
* #%L
* Eclipse Store Storage
* %%
* Copyright (C) 2023 Eclipse Foundation
* %%
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is
* available at https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
* #L%
*/

import org.eclipse.serializer.chars.CharsUtils;
import org.eclipse.serializer.chars.VarString;
import org.eclipse.serializer.chars.XChars;
import org.eclipse.serializer.math.XMath;
import org.eclipse.serializer.persistence.binary.types.BinaryChannelCountProvider;

Expand Down Expand Up @@ -97,7 +77,7 @@ public static void validateParameters(
throw new IllegalArgumentException(
"Specified channel count " + channelCount
+ " is not in the range of valid channel counts: "
+ CharsUtils.mathRangeIncInc(minimumChannelCount(), maximumChannelCount())
+ XChars.mathRangeIncInc(minimumChannelCount(), maximumChannelCount())
+ "."
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@
import java.nio.ByteBuffer;
import java.util.Iterator;

import org.eclipse.store.afs.base.AFSUtils;
import org.eclipse.store.storage.exceptions.StorageException;
import org.eclipse.serializer.afs.types.AFS;
import org.eclipse.serializer.afs.types.AFile;
import org.eclipse.serializer.afs.types.AWritableFile;
import org.eclipse.serializer.chars.CharsUtils;
import org.eclipse.serializer.chars.EscapeHandler;
import org.eclipse.serializer.chars.VarString;
import org.eclipse.serializer.chars.XChars;
Expand All @@ -53,6 +50,8 @@
import org.eclipse.serializer.util.xcsv.XCsvRecordParserCharArray;
import org.eclipse.serializer.util.xcsv.XCsvRowCollector;
import org.eclipse.serializer.util.xcsv.XCsvSegmentsParser;
import org.eclipse.store.afs.base.AFSUtils;
import org.eclipse.store.storage.exceptions.StorageException;


public interface StorageDataConverterTypeCsvToBinary<S>
Expand Down Expand Up @@ -295,7 +294,7 @@ final int parse_byte(
{
j--;
}
this.write_byte(CharsUtils.parse_byteDecimal(data, offset, j - offset + 1));
this.write_byte(XChars.parse_byteDecimal(data, offset, j - offset + 1));
return i;
}

Expand All @@ -320,14 +319,14 @@ final int parse_boolean(

final int literalLength = j - offset + 1;
if(literalLength == this.literalTrue.length
&& CharsUtils.equals(data, offset, this.literalTrue, 0, this.literalTrue.length)
&& XChars.equals(data, offset, this.literalTrue, 0, this.literalTrue.length)
)
{
this.write_boolean(true);
return i;
}
if(literalLength == this.literalFalse.length
&& CharsUtils.equals(data, offset, this.literalFalse, 0, this.literalFalse.length)
&& XChars.equals(data, offset, this.literalFalse, 0, this.literalFalse.length)
)
{
this.write_boolean(false);
Expand Down Expand Up @@ -355,7 +354,7 @@ final int parse_short(
{
j--;
}
this.write_short(CharsUtils.parse_shortDecimal(data, offset, j - offset + 1));
this.write_short(XChars.parse_shortDecimal(data, offset, j - offset + 1));
return i;
}

Expand Down Expand Up @@ -441,7 +440,7 @@ final int parse_int(
{
j--;
}
this.write_int(CharsUtils.parse_intLiteral(data, offset, j - offset + 1));
this.write_int(XChars.parse_intLiteral(data, offset, j - offset + 1));
return i;
}

Expand All @@ -463,7 +462,7 @@ final int parse_float(
{
j--;
}
this.write_float(CharsUtils.parse_float(data, offset, j - offset + 1));
this.write_float(XChars.parse_float(data, offset, j - offset + 1));
return i;
}

Expand All @@ -485,7 +484,7 @@ final int parse_long(
{
j--;
}
this.write_long(CharsUtils.parse_longDecimal(data, offset, j - offset + 1));
this.write_long(XChars.parse_longDecimal(data, offset, j - offset + 1));
return i;
}

Expand All @@ -507,7 +506,7 @@ final int parse_double(
{
j--;
}
this.write_double(CharsUtils.parse_double(data, offset, j - offset + 1));
this.write_double(XChars.parse_double(data, offset, j - offset + 1));
return i;
}

Expand Down Expand Up @@ -649,7 +648,7 @@ final int parseArray_byte(
// parse literal
final int currentElementStart = i;
i = seekSimpleLiteralEnd(data, i, bound, listSeparator, listTerminator);
this.write_byte(CharsUtils.parse_byteDecimal(data, currentElementStart, i - currentElementStart));
this.write_byte(XChars.parse_byteDecimal(data, currentElementStart, i - currentElementStart));

// find literal terminating character (not the same as literal end: there might be white spaces)
i = seekListElementCompletion(data, i, bound, listSeparator, listTerminator);
Expand Down Expand Up @@ -697,12 +696,12 @@ final int parseArray_boolean(
i = seekSimpleLiteralEnd(data, i, bound, listSeparator, listTerminator);

// parse literal. A little more complex for boolean literals.
if(i - elementStart == lengthTrue && CharsUtils.equals(data, elementStart, literalTrue, 0, lengthTrue))
if(i - elementStart == lengthTrue && XChars.equals(data, elementStart, literalTrue, 0, lengthTrue))
{
this.write_boolean(true);
}
else if(i - elementStart == lengthFalse
&& CharsUtils.equals(data, elementStart, literalFalse, 0, lengthFalse)
&& XChars.equals(data, elementStart, literalFalse, 0, lengthFalse)
)
{
this.write_boolean(false);
Expand Down Expand Up @@ -753,7 +752,7 @@ final int parseArray_short(
// parse literal
final int currentElementStart = i;
i = seekSimpleLiteralEnd(data, i, bound, listSeparator, listTerminator);
this.write_short(CharsUtils.parse_shortDecimal(data, currentElementStart, i - currentElementStart));
this.write_short(XChars.parse_shortDecimal(data, currentElementStart, i - currentElementStart));

// find literal terminating character (not the same as literal end: there might be white spaces)
i = seekListElementCompletion(data, i, bound, listSeparator, listTerminator);
Expand Down Expand Up @@ -791,7 +790,7 @@ final int parseArray_int(
// parse literal
final int currentElementStart = i;
i = seekSimpleLiteralEnd(data, i, bound, listSeparator, listTerminator);
this.write_int(CharsUtils.parse_intLiteral(data, currentElementStart, i - currentElementStart));
this.write_int(XChars.parse_intLiteral(data, currentElementStart, i - currentElementStart));

// find literal terminating character (not the same as literal end: there might be white spaces)
i = seekListElementCompletion(data, i, bound, listSeparator, listTerminator);
Expand Down Expand Up @@ -829,7 +828,7 @@ final int parseArray_float(
// parse literal
final int currentElementStart = i;
i = seekSimpleLiteralEnd(data, i, bound, listSeparator, listTerminator);
this.write_float(CharsUtils.parse_float(data, currentElementStart, i - currentElementStart));
this.write_float(XChars.parse_float(data, currentElementStart, i - currentElementStart));

// find literal terminating character (not the same as literal end: there might be white spaces)
i = seekListElementCompletion(data, i, bound, listSeparator, listTerminator);
Expand Down Expand Up @@ -867,7 +866,7 @@ final int parseArray_long(
// parse literal
final int currentElementStart = i;
i = seekSimpleLiteralEnd(data, i, bound, listSeparator, listTerminator);
this.write_long(CharsUtils.parse_longDecimal(data, currentElementStart, i - currentElementStart));
this.write_long(XChars.parse_longDecimal(data, currentElementStart, i - currentElementStart));

// find literal terminating character (not the same as literal end: there might be white spaces)
i = seekListElementCompletion(data, i, bound, listSeparator, listTerminator);
Expand Down Expand Up @@ -905,7 +904,7 @@ final int parseArray_double(
// parse literal
final int currentElementStart = i;
i = seekSimpleLiteralEnd(data, i, bound, listSeparator, listTerminator);
this.write_double(CharsUtils.parse_double(data, currentElementStart, i - currentElementStart));
this.write_double(XChars.parse_double(data, currentElementStart, i - currentElementStart));

// find literal terminating character (not the same as literal end: there might be white spaces)
i = seekListElementCompletion(data, i, bound, listSeparator, listTerminator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/

import org.eclipse.serializer.afs.types.AFile;
import org.eclipse.serializer.chars.CharsUtils;
import org.eclipse.serializer.chars.VarString;
import org.eclipse.serializer.chars.XChars;
import org.eclipse.serializer.collections.EqConstHashTable;
import org.eclipse.serializer.collections.EqHashTable;
import org.eclipse.serializer.collections.types.XGettingTable;
Expand Down Expand Up @@ -70,7 +70,7 @@ public final class Default extends AbstractStatistic implements StorageEntityTyp

public static final void assembleTableHeader(final VarString vs)
{
CharsUtils.assembleNewLinedTabbed(vs, TABLE_COLUMN_NAMES);
XChars.assembleNewLinedTabbed(vs, TABLE_COLUMN_NAMES);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.function.Consumer;

import org.eclipse.serializer.afs.types.AFile;
import org.eclipse.serializer.collections.ArraysUtils;
import org.eclipse.serializer.collections.XArrays;


Expand Down Expand Up @@ -175,7 +174,7 @@ public final synchronized boolean clearUsages(final StorageFileUser fileUser)
{
if(this.usages[i].user == fileUser)
{
ArraysUtils.removeFromIndex(this.usages, this.usagesSize--, i);
XArrays.removeFromIndex(this.usages, this.usagesSize--, i);
this.checkForUsagesArrayClearing();

return true;
Expand All @@ -195,7 +194,7 @@ public final synchronized boolean unregisterUsage(final StorageFileUser fileUser
{
if(this.usages[i].decrement())
{
ArraysUtils.removeFromIndex(this.usages, this.usagesSize--, i);
XArrays.removeFromIndex(this.usages, this.usagesSize--, i);
this.checkForUsagesArrayClearing();

return true;
Expand Down
Loading

0 comments on commit 21addff

Please sign in to comment.