Java Code Examples for org.apache.activemq.artemis.api.core.SimpleString#length()
The following examples show how to use
org.apache.activemq.artemis.api.core.SimpleString#length() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterImpl.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * @return null if <code>filterStr</code> is null or an empty String and a valid filter else * @throws ActiveMQException if the string does not correspond to a valid filter */ public static Filter createFilter(final SimpleString filterStr) throws ActiveMQException { if (filterStr == null || filterStr.length() == 0) { return null; } BooleanExpression booleanExpression; try { booleanExpression = SelectorParser.parse(filterStr.toString()); } catch (Throwable e) { ActiveMQServerLogger.LOGGER.invalidFilter(filterStr); if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) { ActiveMQServerLogger.LOGGER.debug("Invalid filter", e); } throw ActiveMQMessageBundle.BUNDLE.invalidFilter(e, filterStr); } return new FilterImpl(filterStr, booleanExpression); }
Example 2
Source File: TypedPropertiesTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testByteBufStringValuePoolTooLong() { final SimpleString tooLong = new SimpleString("aa"); final ByteBuf bb = Unpooled.buffer(tooLong.sizeof(), tooLong.sizeof()); SimpleString.writeSimpleString(bb, tooLong); final TypedProperties.StringValue.ByteBufStringValuePool pool = new TypedProperties.StringValue.ByteBufStringValuePool(1, tooLong.length() - 1); Assert.assertNotSame(pool.getOrCreate(bb), pool.getOrCreate(bb.resetReaderIndex())); }
Example 3
Source File: SimpleStringTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testByteBufSimpleStringPoolTooLong() { final SimpleString tooLong = new SimpleString("aa"); final ByteBuf bb = Unpooled.buffer(tooLong.sizeof(), tooLong.sizeof()); SimpleString.writeSimpleString(bb, tooLong); final SimpleString.ByteBufSimpleStringPool pool = new SimpleString.ByteBufSimpleStringPool(1, tooLong.length() - 1); Assert.assertNotSame(pool.getOrCreate(bb), pool.getOrCreate(bb.resetReaderIndex())); }
Example 4
Source File: AddressImpl.java From activemq-artemis with Apache License 2.0 | 4 votes |
/** * This method should actually be called `isMatchedBy`. * * @return `true` if this equals otherAddr or this address is matched by a pattern represented by otherAddr */ @Override public boolean matches(final Address otherAddr) { if (otherAddr == null) return false; if (address.equals(otherAddr.getAddress())) return true; final char sepAnyWords = wildcardConfiguration.getAnyWords(); final char sepSingleWord = wildcardConfiguration.getSingleWord(); final int thisAddrPartsLen = addressParts.length; final int thisAddrPartsLastIdx = thisAddrPartsLen - 1; final SimpleString[] otherAddrParts = otherAddr.getAddressParts(); final int otherAddrPartsLen = otherAddrParts.length; final int otherAddrPartsLastIdx = otherAddrPartsLen - 1; int thisIdx = 0; int otherIdx = 0; // iterate through all parts of otherAddr while (otherIdx < otherAddrPartsLen) { // check if we already tested the last part of this address if (thisIdx > thisAddrPartsLastIdx) { // check if last part of otherAddr is the any-words wildcard and report a match if so if (otherIdx == otherAddrPartsLastIdx) { final SimpleString otherAddrLastPart = otherAddrParts[otherAddrPartsLastIdx]; return otherAddrLastPart.length() > 0 && otherAddrLastPart.charAt(0) == sepAnyWords; } return false; } SimpleString thisCurr = addressParts[thisIdx]; final SimpleString otherCurr = otherAddrParts[otherIdx]; final boolean otherCurrPartIsSingleChar = otherCurr.length() == 1; // handle single-word wildcard found in otherAddr if (otherCurrPartIsSingleChar && otherCurr.charAt(0) == sepSingleWord) { thisIdx++; otherIdx++; continue; } // handle any-words wildcard found in otherAddr if (otherCurrPartIsSingleChar && otherCurr.charAt(0) == sepAnyWords) { // if last part of otherAddr is any-words wildcard report a match if (otherIdx == otherAddrPartsLastIdx) return true; SimpleString thisNext; // check if this address has more parts to check if (thisIdx < thisAddrPartsLastIdx) { thisNext = addressParts[thisIdx + 1]; } else { // no more parts to check, thus check the current part against the next part of otherAddr thisNext = thisCurr; } final SimpleString otherNext = otherAddrParts[otherIdx + 1]; // iterate through the remaining parts of this address until the part after the any-words wildcard of otherAddr is matched while (thisCurr != null) { if (thisCurr.equals(otherNext)) { break; } thisIdx++; thisCurr = thisNext; thisNext = thisAddrPartsLastIdx > thisIdx ? addressParts[thisIdx + 1] : null; } // if no further part in this address matched the next part in otherAddr report a mismatch if (thisCurr == null) return false; otherIdx++; continue; } // compare current parts of bothaddresses and report mismatch if they differ if (!thisCurr.equals(otherCurr)) return false; thisIdx++; otherIdx++; } // report match if all parts of this address were checked return thisIdx == thisAddrPartsLen; }
Example 5
Source File: QueueConfig.java From activemq-artemis with Apache License 2.0 | 4 votes |
private static boolean isEmptyOrNull(SimpleString value) { return (value == null || value.length() == 0); }
Example 6
Source File: QueueFactoryImpl.java From activemq-artemis with Apache License 2.0 | 4 votes |
private static boolean isEmptyOrNull(SimpleString value) { return (value == null || value.length() == 0); }