本文整理汇总了Java中com.helger.commons.collection.ArrayHelper.newArray方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayHelper.newArray方法的具体用法?Java ArrayHelper.newArray怎么用?Java ArrayHelper.newArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.collection.ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper.newArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testArray
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
@Test
public void testArray ()
{
final String [] aArray = ArrayHelper.newArray ("a", "b", "c");
assertTrue (EqualsHelper.equalsCollection (aArray, aArray));
assertTrue (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray ("a", "b", "c")));
assertTrue (EqualsHelper.equalsCollection (new String [0], new String [] {}));
assertFalse (EqualsHelper.equalsCollection (aArray, new String [0]));
assertFalse (EqualsHelper.equalsCollection (new String [0], aArray));
assertFalse (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray ("a", "b")));
assertFalse (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray ("A", "b", "c")));
assertFalse (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray ("a", "B", "c")));
assertFalse (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray ("a", "b", "C")));
assertFalse (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray ("a", "b", "c", "d")));
assertFalse (EqualsHelper.equalsCollection (aArray, new CommonsArrayList <> ("a", "b", "c")));
assertFalse (EqualsHelper.equalsCollection (aArray, new CommonsHashSet <> ("a", "b", "c")));
}
示例2: testStdMethods
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
@Test
public void testStdMethods ()
{
final ArrayIterator <String> ae = new ArrayIterator <> (ArrayHelper.newArray ("Hallo",
"Welt",
"from",
"Copenhagen"));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (ae,
new ArrayIterator <> (ArrayHelper.newArray ("Hallo",
"Welt",
"from",
"Copenhagen")));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (ae,
new ArrayIterator <> (ArrayHelper.newArray ("Hallo",
"Welt",
"from")));
ae.next ();
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (ae,
new ArrayIterator <> (ArrayHelper.newArray ("Hallo",
"Welt",
"from",
"Copenhagen")));
}
示例3: testArrayComplex
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
@Test
public void testArrayComplex ()
{
final ICommonsList <String> [] aArray = ArrayHelper.newArray (new CommonsArrayList <> ("a", "b"),
new CommonsArrayList <> ("c", "d"));
assertTrue (EqualsHelper.equalsCollection (aArray, aArray));
assertTrue (EqualsHelper.equalsCollection (aArray,
ArrayHelper.newArray (new CommonsArrayList <> ("a", "b"),
new CommonsArrayList <> ("c", "d"))));
assertTrue (EqualsHelper.equalsCollection (new ICommonsList <?> [0], new ICommonsList <?> [] {}));
assertFalse (EqualsHelper.equalsCollection (aArray, new ICommonsList <?> [0]));
assertFalse (EqualsHelper.equalsCollection (new ICommonsList <?> [0], aArray));
assertFalse (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray (new CommonsArrayList <> ("a", "b"))));
assertFalse (EqualsHelper.equalsCollection (aArray,
ArrayHelper.newArray (new CommonsArrayList <> ("A", "b"),
new CommonsArrayList <> ("c", "d"))));
assertFalse (EqualsHelper.equalsCollection (aArray,
ArrayHelper.newArray (new CommonsArrayList <> ("a", "b"),
new CommonsArrayList <> ("c", "D"))));
assertFalse (EqualsHelper.equalsCollection (aArray,
ArrayHelper.newArray (new CommonsArrayList <> ("a", "b"),
new CommonsArrayList <> ("c", "d"),
new CommonsArrayList <> ("e", "f"))));
assertFalse (EqualsHelper.equalsCollection (aArray,
ArrayHelper.newArray (new CommonsArrayList <> ("a", "b"),
(ICommonsList <String>) null)));
assertFalse (EqualsHelper.equalsCollection (aArray, new CommonsArrayList <> ("a", "b", "c")));
assertFalse (EqualsHelper.equalsCollection (aArray, new CommonsHashSet <> ("a", "b", "c")));
assertFalse (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray ("a", "b", "c")));
assertFalse (EqualsHelper.equalsCollection (aArray, ArrayHelper.newArray ("a", null, "c")));
}
示例4: testBasic
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
@Test
public void testBasic ()
{
assertSame (IterableIterator.createEmpty (), IterableIterator.createEmpty ());
IIterableIterator <String> iit = new IterableIterator <> (ArrayHelper.newArray ("Hallo",
"Welt",
"from",
"Copenhagen"));
assertNotNull (iit);
assertNotNull (iit.iterator ());
assertTrue (iit.hasNext ());
assertEquals ("Hallo", iit.next ());
iit = new IterableIterator <> (CollectionHelper.newList ("Hallo", "Welt", "from", "Copenhagen"));
iit.next ();
iit.remove ();
assertEquals (3, CollectionHelper.newList (new IterableIterator <> (new String [] { "a", "b", "c" })).size ());
assertEquals (3,
CollectionHelper.newList (new IterableIterator <> (CollectionHelper.newList ("a", "b", "c")))
.size ());
assertEquals (3,
CollectionHelper.newList (new IterableIterator <> (CollectionHelper.newList ("a", "b", "c")
.iterator ()))
.size ());
CommonsTestHelper.testToStringImplementation (iit);
try
{
new IterableIterator <> ((Iterator <String>) null);
fail ();
}
catch (final NullPointerException ex)
{}
}
示例5: _convertToPackage
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
@Nonnull
private static String _convertToPackage (@Nonnull final String sNamespaceURI)
{
// Lowercase everything
String s = sNamespaceURI.toLowerCase (Locale.US);
String [] aParts;
final URL aURL = URLHelper.getAsURL (sNamespaceURI);
if (aURL != null)
{
// Host
String sHost = aURL.getHost ();
// Kick static prefix: www.helger.com -> helger.com
sHost = StringHelper.trimStart (sHost, "www.");
// Reverse domain: helger.com -> com.helger
final List <String> x = CollectionHelper.getReverseList (StringHelper.getExploded ('.', sHost));
// Path in regular order:
final String sPath = StringHelper.trimStart (aURL.getPath (), '/');
x.addAll (StringHelper.getExploded ('/', sPath));
// Convert to array
aParts = ArrayHelper.newArray (x, String.class);
}
else
{
// Kick known prefixes
for (final String sPrefix : new String [] { "urn:", "http://" })
if (s.startsWith (sPrefix))
{
s = s.substring (sPrefix.length ());
break;
}
// Replace all illegal characters
s = StringHelper.replaceAll (s, ':', '.');
s = StringHelper.replaceAll (s, '-', '_');
aParts = StringHelper.getExplodedArray ('.', s);
}
// Split into pieces and replace all illegal package parts (e.g. only
// numeric) with valid ones
for (int i = 0; i < aParts.length; ++i)
aParts[i] = RegExHelper.getAsIdentifier (aParts[i]);
return StringHelper.getImploded (".", aParts);
}
示例6: _convertToPackage
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
@Nonnull
private static String _convertToPackage (@Nonnull final String sNamespaceURI)
{
// Lowercase everything
String s = sNamespaceURI.toLowerCase (Locale.US);
String [] aParts;
final URL aURL = URLHelper.getAsURL (sNamespaceURI);
if (aURL != null)
{
// Host
String sHost = aURL.getHost ();
// Kick static prefix: www.helger.com -> helger.com
sHost = StringHelper.trimStart (sHost, "www.");
// Reverse domain: helger.com -> com.helger
final ICommonsList <String> x = StringHelper.getExploded ('.', sHost);
x.reverse ();
// Path in regular order:
final String sPath = StringHelper.trimStart (aURL.getPath (), '/');
x.addAll (StringHelper.getExploded ('/', sPath));
// Convert to array
aParts = ArrayHelper.newArray (x, String.class);
}
else
{
// Kick known prefixes
for (final String sPrefix : new String [] { "urn:", "http://" })
if (s.startsWith (sPrefix))
{
s = s.substring (sPrefix.length ());
break;
}
// Replace all illegal characters
s = StringHelper.replaceAll (s, ':', '.');
s = StringHelper.replaceAll (s, '-', '_');
aParts = StringHelper.getExplodedArray ('.', s);
}
// Split into pieces and replace all illegal package parts (e.g. only
// numeric) with valid ones
for (int i = 0; i < aParts.length; ++i)
aParts[i] = RegExHelper.getAsIdentifier (aParts[i]);
return StringHelper.getImploded (".", aParts);
}