static String parserNameFromConfiguration(final Class<?> type, final NakedObjectConfiguration configuration) { final String key = PARSER_NAME_KEY_PREFIX + type.getCanonicalName() + PARSER_NAME_KEY_SUFFIX; final String parserName = configuration.getString(key); return !StringUtils.isEmpty(parserName) ? parserName : null; }
private static String naturalize(final String name, final int startingPosition) { if (name.length() <= startingPosition) { throw new IllegalArgumentException("string shorter than starting position provided"); } final StringBuffer s = new StringBuffer(name.length() - startingPosition); for (int j = startingPosition; j < name.length(); j++) { // process english name - add spaces if ((j > startingPosition) && isStartOfNewWord(name.charAt(j), name.charAt(j - 1))) { s.append(' '); } if (j == startingPosition) { s.append(Character.toUpperCase(name.charAt(j))); } else { s.append(name.charAt(j)); } } final String str = s.toString(); return str; }
public static String naturalize(final String name) { return naturalize(name, 0); }
@Factory public static Matcher<String> containsStripNewLines(final String expected) { final String strippedExpected = StringUtils.stripNewLines(expected); return new StringContains(strippedExpected) { @Override public boolean matchesSafely(final String actual) { return super.matchesSafely(StringUtils.stripNewLines(actual)); } @Override public void describeTo(final Description description) { description.appendText("a string (ignoring new lines) containing").appendValue(strippedExpected); } }; }
private String checkPrefix(final String methodName) { final String prefix = new MethodPrefixFinder().findPrefix(methodName); if (StringUtils.in(prefix, Constants.INVALID_PREFIXES)) { throw new UnsupportedOperationException(String.format( "Cannot invoke methods with prefix '%s'; use only get/set/addTo/removeFrom/action", prefix)); } return prefix; }
private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final String servletPath = StringUtils.stripLeadingSlash(request.getServletPath()); LOG.info("request: " + servletPath); // try to load from classpath InputStream is = Resources.getResourceAsStream(servletPath); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } // otherwise, try to load from filesystem is = getRealPath(request); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } }
@Factory public static Matcher<String> startsWithStripNewLines(final String expected) { final String strippedExpected = StringUtils.stripNewLines(expected); return new StringStartsWith(strippedExpected) { @Override public boolean matchesSafely(final String actual) { return super.matchesSafely(StringUtils.stripNewLines(actual)); } @Override public void describeTo(final Description description) { description.appendText("a string (ignoring new lines) starting with").appendValue(strippedExpected); } }; }
private String checkPrefix(final String methodName) { final String prefix = new MethodPrefixFinder().findPrefix(methodName); if (StringUtils.in(prefix, Constants.INVALID_PREFIXES)) { throw new UnsupportedOperationException(String.format( "Cannot invoke methods with prefix '%s'; use only get/set/addTo/removeFrom/action", prefix)); } return prefix; }
private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final String servletPath = StringUtils.stripLeadingSlash(request.getServletPath()); LOG.info("request: " + servletPath); // try to load from classpath InputStream is = Resources.getResourceAsStream(servletPath); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } // otherwise, try to load from filesystem is = getRealPath(request); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } }
static String encoderDecoderNameFromConfiguration(final Class<?> type, final NakedObjectConfiguration configuration) { final String key = ENCODER_DECODER_NAME_KEY_PREFIX + type.getCanonicalName() + ENCODER_DECODER_NAME_KEY_SUFFIX; final String encoderDecoderName = configuration.getString(key); return !StringUtils.isEmpty(encoderDecoderName) ? encoderDecoderName : null; }
@Factory public static Matcher<String> endsWithStripNewLines(final String expected) { final String strippedExpected = StringUtils.stripNewLines(expected); return new StringEndsWith(strippedExpected) { @Override public boolean matchesSafely(final String actual) { return super.matchesSafely(StringUtils.stripNewLines(actual)); } @Override public void describeTo(final Description description) { description.appendText("a string (ignoring new lines) ending with").appendValue(strippedExpected); } }; }
private String checkPrefix(final String methodName) { final String prefix = new MethodPrefixFinder().findPrefix(methodName); if (StringUtils.in(prefix, Constants.INVALID_PREFIXES)) { throw new UnsupportedOperationException(String.format( "Cannot invoke methods with prefix '%s'; use only get/set/addTo/removeFrom/action", prefix)); } return prefix; }
public static String naturalize(final String name) { return naturalize(name, 0); }
private static String naturalize(final String name, final int startingPosition) { if (name.length() <= startingPosition) { throw new IllegalArgumentException("string shorter than starting position provided"); } final StringBuffer s = new StringBuffer(name.length() - startingPosition); for (int j = startingPosition; j < name.length(); j++) { // process english name - add spaces if ((j > startingPosition) && isStartOfNewWord(name.charAt(j), name.charAt(j - 1))) { s.append(' '); } if (j == startingPosition) { s.append(Character.toUpperCase(name.charAt(j))); } else { s.append(name.charAt(j)); } } final String str = s.toString(); return str; }
static String defaultsProviderNameFromConfiguration(final Class<?> type, final NakedObjectConfiguration configuration) { final String key = DEFAULTS_PROVIDER_NAME_KEY_PREFIX + type.getCanonicalName() + DEFAULTS_PROVIDER_NAME_KEY_SUFFIX; final String defaultsProviderName = configuration.getString(key); return !StringUtils.isEmpty(defaultsProviderName) ? defaultsProviderName : null; }
@Factory public static Matcher<String> containsStripNewLines(final String expected) { final String strippedExpected = StringUtils.stripNewLines(expected); return new StringContains(strippedExpected) { @Override public boolean matchesSafely(final String actual) { return super.matchesSafely(StringUtils.stripNewLines(actual)); } @Override public void describeTo(final Description description) { description.appendText("a string (ignoring new lines) containing").appendValue(strippedExpected); } }; }
public static String naturalName(final String name) { int pos = 0; // find first upper case character while ((pos < name.length()) && Character.isLowerCase(name.charAt(pos))) { pos++; } if (pos == name.length()) { return "invalid name"; } return naturalize(name, pos); }
static String encoderDecoderNameFromConfiguration(final Class<?> type, final NakedObjectConfiguration configuration) { final String key = ENCODER_DECODER_NAME_KEY_PREFIX + type.getCanonicalName() + ENCODER_DECODER_NAME_KEY_SUFFIX; final String encoderDecoderName = configuration.getString(key); return !StringUtils.isEmpty(encoderDecoderName) ? encoderDecoderName : null; }
@Factory public static Matcher<String> startsWithStripNewLines(final String expected) { final String strippedExpected = StringUtils.stripNewLines(expected); return new StringStartsWith(strippedExpected) { @Override public boolean matchesSafely(final String actual) { return super.matchesSafely(StringUtils.stripNewLines(actual)); } @Override public void describeTo(final Description description) { description.appendText("a string (ignoring new lines) starting with").appendValue(strippedExpected); } }; }
public static String naturalName(final String name) { int pos = 0; // find first upper case character while ((pos < name.length()) && Character.isLowerCase(name.charAt(pos))) { pos++; } if (pos == name.length()) { return "invalid name"; } return naturalize(name, pos); }