steps.add(new Step() { @Override public int step() { return step1(); //or the code directly } }); steps.add(new Step() { @Override public int step() { return step2(); } });
/** Lazily computes some information about our name. */ private void parseStepName() { String prefix; int colonIndex = name.indexOf(":"); if (colonIndex == -1) { // no colon, so localpart is simply name (even if it's "*") prefix = null; localPart = name; } else { prefix = name.substring(0, colonIndex); localPart = name.substring(colonIndex + 1); } uri = mapPrefix(prefix); }
for (int i = 0; i < stepsJSONArray.length(); i++) { stepJSONObject = stepsJSONArray.getJSONObject(i); step = new Step(); JSONObject stepDistanceJSONObject = stepJSONObject.getJSONObject(DISTANCE); step.setDistance(new Distance(stepDistanceJSONObject.getString(TEXT), stepDistanceJSONObject.getLong(VALUE))); stepDurationJSONObject = stepJSONObject.getJSONObject(DURATION); step.setDuration(new Duration(stepDurationJSONObject.getString(TEXT), stepDurationJSONObject.getLong(VALUE))); stepEndLocationJSONObject = stepJSONObject.getJSONObject(END_LOCATION); stepEndLocationLatLng = new LatLng(stepEndLocationJSONObject.getDouble(LATITUDE), stepEndLocationJSONObject.getDouble(LONGITUDE)); step.setEndLocation(stepEndLocationLatLng); step.setHtmlInstructions(stepJSONObject.getString(HTML_INSTRUCTION)); legPolyLineJSONObject = stepJSONObject.getJSONObject(POLYLINE); encodedString = legPolyLineJSONObject.getString(POINTS); step.setPoints(decodePolyLines(encodedString)); stepStartLocationJSONObject = stepJSONObject.getJSONObject(START_LOCATION); stepStartLocationLatLng = new LatLng(stepStartLocationJSONObject.getDouble(LATITUDE), stepStartLocationJSONObject.getDouble(LONGITUDE)); step.setStartLocation(stepStartLocationLatLng); leg.addStep(step);
public class SomeClass{ public static void main(String[] args) { Step step = new Step("hello"); System.out.println(" " + step.getMessage()); } }
/** Simple command-line parser interface, primarily for testing. */ public static void main(String args[]) throws ParseException { SPathParser parser = new SPathParser(System.in); Path p = parser.expression(); java.util.List l = p.getSteps(); // output for simple testing System.out.println(); if (p instanceof AbsolutePath) System.out.println("Root: /"); for (int i = 0; i < l.size(); i++) { Step s = (Step) l.get(i); System.out.print("Step: " + s.getName()); if (s.isDepthUnlimited()) System.out.print("(*)"); System.out.println(); } }
public static boolean nodeMatchesStep(Step s, String uri, String localName, String qName, Attributes a) { // if the name doesn't match, then we've got a loser if (!s.isMatchingName(uri, localName)) return false; // it's still in the game; check the predicates List l = s.getPredicates(); for (int i = 0; l != null && i < l.size(); i++) { Predicate p = (Predicate) l.get(i); if (!(p instanceof AttributePredicate)) throw new UnsupportedOperationException ("only attribute predicates are supported by filter"); if (!((AttributePredicate) p).isMatchingAttribute(a)) return false; // all predicates must match } // it's survived return true; }
} else if (!currentStep.isDepthUnlimited()) {
/** Simple command-line parser interface, primarily for testing. */ public static void main(String args[]) throws ParseException { SPathParser parser = new SPathParser(System.in); Path p = parser.expression(); java.util.List l = p.getSteps(); // output for simple testing System.out.println(); if (p instanceof AbsolutePath) System.out.println("Root: /"); for (int i = 0; i < l.size(); i++) { Step s = (Step) l.get(i); System.out.print("Step: " + s.getName()); if (s.isDepthUnlimited()) System.out.print("(*)"); System.out.println(); } }
public static boolean nodeMatchesStep(Step s, String uri, String localName, String qName, Attributes a) { // if the name doesn't match, then we've got a loser if (!s.isMatchingName(uri, localName)) return false; // it's still in the game; check the predicates List l = s.getPredicates(); for (int i = 0; l != null && i < l.size(); i++) { Predicate p = (Predicate) l.get(i); if (!(p instanceof AttributePredicate)) throw new UnsupportedOperationException ("only attribute predicates are supported by filter"); if (!((AttributePredicate) p).isMatchingAttribute(a)) return false; // all predicates must match } // it's survived return true; }
} else if (!currentStep.isDepthUnlimited()) {
/** Simple command-line parser interface, primarily for testing. */ public static void main(String args[]) throws ParseException { SPathParser parser = new SPathParser(System.in); Path p = parser.expression(); java.util.List l = p.getSteps(); // output for simple testing System.out.println(); if (p instanceof AbsolutePath) System.out.println("Root: /"); for (int i = 0; i < l.size(); i++) { Step s = (Step) l.get(i); System.out.print("Step: " + s.getName()); if (s.isDepthUnlimited()) System.out.print("(*)"); System.out.println(); } }
public static boolean nodeMatchesStep(Step s, String uri, String localName, String qName, Attributes a) { // if the name doesn't match, then we've got a loser if (!s.isMatchingName(uri, localName)) return false; // it's still in the game; check the predicates List l = s.getPredicates(); for (int i = 0; l != null && i < l.size(); i++) { Predicate p = (Predicate) l.get(i); if (!(p instanceof AttributePredicate)) throw new UnsupportedOperationException ("only attribute predicates are supported by filter"); if (!((AttributePredicate) p).isMatchingAttribute(a)) return false; // all predicates must match } // it's survived return true; }
scala> class Step(@scala.reflect.BeanProperty val message:String ) defined class Step scala> val s = new Step("asdf") s: Step = Step@71e13a2c scala> s.message res6: String = asdf scala> s.getMessage res10: String = asdf
/** Lazily computes some information about our name. */ private void parseStepName() { String prefix; int colonIndex = name.indexOf(":"); if (colonIndex == -1) { // no colon, so localpart is simply name (even if it's "*") prefix = null; localPart = name; } else { prefix = name.substring(0, colonIndex); localPart = name.substring(colonIndex + 1); } uri = mapPrefix(prefix); }
} else if (!currentStep.isDepthUnlimited()) {
/** Simple command-line parser interface, primarily for testing. */ public static void main(String args[]) throws ParseException { SPathParser parser = new SPathParser(System.in); Path p = parser.expression(); java.util.List l = p.getSteps(); // output for simple testing System.out.println(); if (p instanceof AbsolutePath) System.out.println("Root: /"); for (int i = 0; i < l.size(); i++) { Step s = (Step) l.get(i); System.out.print("Step: " + s.getName()); if (s.isDepthUnlimited()) System.out.print("(*)"); System.out.println(); } }
public static boolean nodeMatchesStep(Step s, String uri, String localName, String qName, Attributes a) { // if the name doesn't match, then we've got a loser if (!s.isMatchingName(uri, localName)) return false; // it's still in the game; check the predicates List l = s.getPredicates(); for (int i = 0; l != null && i < l.size(); i++) { Predicate p = (Predicate) l.get(i); if (!(p instanceof AttributePredicate)) throw new UnsupportedOperationException ("only attribute predicates are supported by filter"); if (!((AttributePredicate) p).isMatchingAttribute(a)) return false; // all predicates must match } // it's survived return true; }