public String build() throws MalformedParametersException { if(this.baseURL == null || this.baseURL.isEmpty()) { throw new MalformedParametersException("Cannot build URL with empty host"); } StringBuilder sb = new StringBuilder(); sb.append(this.baseURL); if(databaseName != null && !databaseName.isEmpty()) { sb.append("/").append(databaseName); if(collectionName != null && !collectionName.isEmpty()) { sb.append("/").append(collectionName); if(documentId != null && !documentId.isEmpty()) { sb.append("/").append(documentId); } } } return sb.toString(); }
public static Ellipse createFromSvg(Element element) throws MalformedParametersException { if (!element.getName().toLowerCase().trim().equals("ellipse")) { throw new MalformedParametersException("SVG Element is not an Ellipse."); } Ellipse ellipse = new Ellipse(); ellipse.setCenterX(Double.parseDouble(element.getAttributeValue("cx"))); ellipse.setCenterY(Double.parseDouble(element.getAttributeValue("cy"))); ellipse.setRadiusX(Double.parseDouble(element.getAttributeValue("rx"))); ellipse.setRadiusY(Double.parseDouble(element.getAttributeValue("ry"))); ellipse.setFill(Color.web(element.getAttributeValue("fill"), Double.parseDouble(element.getAttributeValue("fill-opacity")))); ellipse.setStroke(Color.web(element.getAttributeValue("stroke"), Double.parseDouble(element.getAttributeValue("stroke-opacity")))); ellipse.setStrokeWidth(Double.parseDouble(element.getAttributeValue("stroke-width"))); String svgTransforms = element.getAttributeValue("transform"); if (svgTransforms != null) { List<Transform> transforms = ShapeUtils.getTransformsFromSvg(svgTransforms); ellipse.getTransforms().addAll(transforms); } return ellipse; }
public static Line createFromSvg(Element element) throws MalformedParametersException { if (!element.getName().toLowerCase().trim().equals("line")) { throw new MalformedParametersException("SVG Element is not a Line."); } Line line = new Line(); line.setStartX(Double.parseDouble(element.getAttributeValue("x1"))); line.setStartY(Double.parseDouble(element.getAttributeValue("y1"))); line.setEndX(Double.parseDouble(element.getAttributeValue("x2"))); line.setEndY(Double.parseDouble(element.getAttributeValue("y2"))); line.setStroke(Color.web(element.getAttributeValue("stroke"), Double.parseDouble(element.getAttributeValue("stroke-opacity")))); line.setStrokeWidth(Double.parseDouble(element.getAttributeValue("stroke-width"))); String svgTransforms = element.getAttributeValue("transform"); if (svgTransforms != null) { List<Transform> transforms = ShapeUtils.getTransformsFromSvg(svgTransforms); line.getTransforms().addAll(transforms); } return line; }
public static Image createFromSvg(Element element) throws MalformedParametersException { if (!element.getName().toLowerCase().trim().equals("image")) { throw new MalformedParametersException("SVG Element is not a Rectangle."); } Image image = new Image(); image.setImage(getImageFromBase64(element.getAttributeValue("href", SvgController.XLINK_NAMESPACE))); image.setX(Double.parseDouble(element.getAttributeValue("x"))); image.setY(Double.parseDouble(element.getAttributeValue("y"))); image.setFitWidth(Double.parseDouble(element.getAttributeValue("width"))); image.setFitHeight(Double.parseDouble(element.getAttributeValue("height"))); String svgTransforms = element.getAttributeValue("transform"); if (svgTransforms != null) { List<Transform> transforms = ShapeUtils.getTransformsFromSvg(svgTransforms); image.getTransforms().addAll(transforms); } return image; }
public static Rectangle createFromSvg(Element element) throws MalformedParametersException { if (!element.getName().toLowerCase().trim().equals("rect")) { throw new MalformedParametersException("SVG Element is not a Rectangle."); } Rectangle rectangle = new Rectangle(); rectangle.setX(Double.parseDouble(element.getAttributeValue("x"))); rectangle.setY(Double.parseDouble(element.getAttributeValue("y"))); rectangle.setWidth(Double.parseDouble(element.getAttributeValue("width"))); rectangle.setHeight(Double.parseDouble(element.getAttributeValue("height"))); rectangle.setFill(Color.web(element.getAttributeValue("fill"), Double.parseDouble(element.getAttributeValue("fill-opacity")))); rectangle.setStroke(Color.web(element.getAttributeValue("stroke"), Double.parseDouble(element.getAttributeValue("stroke-opacity")))); rectangle.setStrokeWidth(Double.parseDouble(element.getAttributeValue("stroke-width"))); String svgTransforms = element.getAttributeValue("transform"); if (svgTransforms != null) { List<Transform> transforms = ShapeUtils.getTransformsFromSvg(svgTransforms); rectangle.getTransforms().addAll(transforms); } return rectangle; }
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException { try { System.err.println("Trying " + cls); final Method method = cls.getMethod("m", int.class, int.class); final Parameter[] params = method.getParameters(); System.err.println("Name " + params[0].getName()); System.err.println("Did not see expected exception"); errors++; } catch(MalformedParametersException e) { System.err.println("Expected exception seen"); } }
private String findParameterName(AnnotatedParameter annotatedParameter) { Parameter[] params; try { params = getParameters(annotatedParameter.getOwner()); } catch (MalformedParametersException e) { return null; } Parameter p = params[annotatedParameter.getIndex()]; return p.isNamePresent() ? p.getName() : null; }