### Question:
StringValidateEncodeUtils { @SuppressWarnings({"UnnecessaryContinue"}) public static boolean descendOnlyFilePath(String path) { String[] pathSegments = path.split("/"); int i = 0; for (int indxOrigSegs = 0; indxOrigSegs < pathSegments.length; indxOrigSegs++) { String s = pathSegments[indxOrigSegs]; if (s.equals(".")) continue; else if (s.equals("..")) { if (i == 0) return false; i--; } else { i++; } } return true; } private  StringValidateEncodeUtils(); static boolean validSingleLineString(String singleLineString); @SuppressWarnings({"SimplifiableIfStatement"}) static boolean validPath(String path); @SuppressWarnings({"SimplifiableIfStatement"}) static boolean validFilePath(String path); @SuppressWarnings({"SimplifiableIfStatement"}) static boolean validUriString(String uri); static boolean validIdString(String id); static boolean containsAngleBracketCharacters(String string); static boolean containsAmpersandCharacters(String string); static boolean containsBackslashCharacters(String string); static boolean validDecimalNumber(String number); @SuppressWarnings({"SimplifiableIfStatement"}) static boolean validBooleanString(String boolString); static boolean validAlphanumericString(String alphNumString); static boolean validAlphanumericStringConstrainedSet(String alphNumString, String[] constrainedSet,
      boolean ignoreCase); @SuppressWarnings({"UnnecessaryContinue"}) static boolean descendOnlyFilePath(String path); static boolean validPercentHexOctetsString(String percentHexOctetsString); static String unicodeCodePoint2PercentHexString(int codePoint, String charsetName); final static String CHARACTER_ENCODING_UTF_8; }### Answer:
@Test public void testDescendOnlyFilePath() { assertTrue(StringValidateEncodeUtils.descendOnlyFilePath("./fred/frank/john")); assertTrue(StringValidateEncodeUtils.descendOnlyFilePath("./fred/frank/../john")); assertTrue(StringValidateEncodeUtils.descendOnlyFilePath("./fred/frank/../../john")); assertFalse(StringValidateEncodeUtils.descendOnlyFilePath("./fred/frank/../../../john")); assertFalse(StringValidateEncodeUtils.descendOnlyFilePath("../fred/frank/john")); assertFalse(StringValidateEncodeUtils.descendOnlyFilePath("../../fred/frank/john")); assertTrue(StringValidateEncodeUtils.descendOnlyFilePath("./fred/frank/john/..")); assertTrue(StringValidateEncodeUtils.descendOnlyFilePath("./fred/frank/john/../..")); assertTrue(StringValidateEncodeUtils.descendOnlyFilePath("./fred/frank/john/../../..")); assertFalse(StringValidateEncodeUtils.descendOnlyFilePath("./fred/frank/john/../../../..")); assertTrue(StringValidateEncodeUtils.descendOnlyFilePath("./fred/../frank/john")); assertTrue(StringValidateEncodeUtils.descendOnlyFilePath("./fred/../frank/../john")); assertFalse(StringValidateEncodeUtils.descendOnlyFilePath("./fred/../frank/../../john")); }