id
stringlengths
7
14
text
stringlengths
1
106k
1024699_2
public static void checkUrlIsValid(String url) throws IllegalArgumentException { logger.debug("Url is : {}",url); boolean urlIsValid; Pattern p = Pattern.compile(URL_PATTERN); Matcher m = p.matcher(url); if (!m.matches()) { // not an url ? maybe an ip address p = Pattern.compile(IP_ADDRESS_PATTERN); m = p.matcher(url); urlIsValid = m.matches(); }else{ urlIsValid = true; } if(!urlIsValid){ throw new IllegalArgumentException("Url is not valid"); } //nothing is better than testing for real URI.create(url); logger.debug("urlIsValid : {}",urlIsValid); }
1024699_3
public static void checkUrlIsValid(String url) throws IllegalArgumentException { logger.debug("Url is : {}",url); boolean urlIsValid; Pattern p = Pattern.compile(URL_PATTERN); Matcher m = p.matcher(url); if (!m.matches()) { // not an url ? maybe an ip address p = Pattern.compile(IP_ADDRESS_PATTERN); m = p.matcher(url); urlIsValid = m.matches(); }else{ urlIsValid = true; } if(!urlIsValid){ throw new IllegalArgumentException("Url is not valid"); } //nothing is better than testing for real URI.create(url); logger.debug("urlIsValid : {}",urlIsValid); }
1024699_4
public static Album findAlbumFromAlbumName(Album rootAlbum, int albumName) { logger.debug("rootAlbum is : {} -- albumName is : {}",rootAlbum,albumName); Album albumFound=null; if (rootAlbum.getName() == albumName&& !rootAlbum.isFakeAlbum()) { albumFound= rootAlbum; } for (Album album : rootAlbum.getSubAlbums()) { if (album.getName() == albumName && !album.isFakeAlbum()) { albumFound= album; break; } Album fromAlbumName = findAlbumFromAlbumName(album, albumName); if (fromAlbumName != null && !fromAlbumName.isFakeAlbum()) { albumFound= fromAlbumName; } } logger.debug("albumFound is : {}",albumFound); return albumFound; }
1024699_5
public HashMap<String, String> fetchImages(String galleryUrl, int albumName) throws GalleryConnectionException { List<NameValuePair> nameValuePairsFetchImages = new ArrayList<NameValuePair>(); nameValuePairsFetchImages.add(FETCH_ALBUMS_IMAGES_CMD_NAME_VALUE_PAIR); nameValuePairsFetchImages.add(new BasicNameValuePair( "g2_form[set_albumName]", "" + albumName)); HashMap<String, String> properties = sendCommandToGallery(galleryUrl, nameValuePairsFetchImages, null); return properties; }
1024699_6
public HashMap<String, String> fetchImages(String galleryUrl, int albumName) throws GalleryConnectionException { List<NameValuePair> nameValuePairsFetchImages = new ArrayList<NameValuePair>(); nameValuePairsFetchImages.add(FETCH_ALBUMS_IMAGES_CMD_NAME_VALUE_PAIR); nameValuePairsFetchImages.add(new BasicNameValuePair( "g2_form[set_albumName]", "" + albumName)); HashMap<String, String> properties = sendCommandToGallery(galleryUrl, nameValuePairsFetchImages, null); return properties; }
1024699_7
public void loginToGallery(String galleryUrl, String user, String password) throws ImpossibleToLoginException { // we reset the last login sessionCookies.clear(); sessionCookies.add(new BasicClientCookie("", "")); List<NameValuePair> sb = new ArrayList<NameValuePair>(); sb.add(LOGIN_CMD_NAME_VALUE_PAIR); sb.add(new BasicNameValuePair("g2_form[uname]", "" + user)); sb.add(new BasicNameValuePair("g2_form[password]", "" + password)); HashMap<String, String> properties; try { properties = sendCommandToGallery(galleryUrl, sb, null); } catch (GalleryConnectionException e) { throw new ImpossibleToLoginException(e); } // auth_token retrieval, used by G2 against cross site forgery authToken = null; if (properties.get("status") != null) { if (properties.get("status").equals(GR_STAT_SUCCESS)) { authToken = properties.get("auth_token"); } else { throw new ImpossibleToLoginException( properties.get("status_text")); } } //the login request did not return properties; issue #24 if(properties.isEmpty()){ throw new ImpossibleToLoginException("The Gallery did not return login properties; check your gallery installation and/or your settings" ); } }
1024699_8
public void loginToGallery(String galleryUrl, String user, String password) throws ImpossibleToLoginException { // we reset the last login sessionCookies.clear(); sessionCookies.add(new BasicClientCookie("", "")); List<NameValuePair> sb = new ArrayList<NameValuePair>(); sb.add(LOGIN_CMD_NAME_VALUE_PAIR); sb.add(new BasicNameValuePair("g2_form[uname]", "" + user)); sb.add(new BasicNameValuePair("g2_form[password]", "" + password)); HashMap<String, String> properties; try { properties = sendCommandToGallery(galleryUrl, sb, null); } catch (GalleryConnectionException e) { throw new ImpossibleToLoginException(e); } // auth_token retrieval, used by G2 against cross site forgery authToken = null; if (properties.get("status") != null) { if (properties.get("status").equals(GR_STAT_SUCCESS)) { authToken = properties.get("auth_token"); } else { throw new ImpossibleToLoginException( properties.get("status_text")); } } //the login request did not return properties; issue #24 if(properties.isEmpty()){ throw new ImpossibleToLoginException("The Gallery did not return login properties; check your gallery installation and/or your settings" ); } }
1024699_9
public void loginToGallery(String galleryUrl, String user, String password) throws ImpossibleToLoginException { // we reset the last login sessionCookies.clear(); sessionCookies.add(new BasicClientCookie("", "")); List<NameValuePair> sb = new ArrayList<NameValuePair>(); sb.add(LOGIN_CMD_NAME_VALUE_PAIR); sb.add(new BasicNameValuePair("g2_form[uname]", "" + user)); sb.add(new BasicNameValuePair("g2_form[password]", "" + password)); HashMap<String, String> properties; try { properties = sendCommandToGallery(galleryUrl, sb, null); } catch (GalleryConnectionException e) { throw new ImpossibleToLoginException(e); } // auth_token retrieval, used by G2 against cross site forgery authToken = null; if (properties.get("status") != null) { if (properties.get("status").equals(GR_STAT_SUCCESS)) { authToken = properties.get("auth_token"); } else { throw new ImpossibleToLoginException( properties.get("status_text")); } } //the login request did not return properties; issue #24 if(properties.isEmpty()){ throw new ImpossibleToLoginException("The Gallery did not return login properties; check your gallery installation and/or your settings" ); } }
1025574_0
public ServiceDescription describe() { ServiceDescription.Builder mds = new ServiceDescription.Builder(NAME, Validate.class.getCanonicalName()); mds.description("A validator for ODF file, based on the ODF Toolkit project ODF Validator."); mds.author("Andrew Jackson <Andrew.Jackson@bl.uk>"); try { mds.furtherInfo(new URI("http://odftoolkit.org/projects/odftoolkit/pages/ODFValidator")); } catch (URISyntaxException e) { } mds.classname(this.getClass().getCanonicalName()); return mds.build(); }
1025574_1
public ValidateResult validate(DigitalObject dob, URI format, List<Parameter> parameters) { return ODFValidatorWrapper.validateODF(dob,format); }
1025574_2
String toXMlFormatted() throws JAXBException, UnsupportedEncodingException { //Create marshaller Marshaller m = jc.createMarshaller(); m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE ); ByteArrayOutputStream bos = new ByteArrayOutputStream(); m.marshal(this, bos); return bos.toString("UTF-8"); }
1025574_3
public static ToolSpec fromInputStream( InputStream input ) throws FileNotFoundException, JAXBException { Unmarshaller u = jc.createUnmarshaller(); return (ToolSpec) u.unmarshal(new StreamSource(input)); }
1025574_4
public static void main(String[] args) { /* FIXME, point to log4j.properties instead of doing this? */ /* java.util.logging.Logger.getLogger("com.sun.xml.ws.model").setLevel(java.util.logging.Level.WARNING); java.util.logging.Logger.getAnonymousLogger().setLevel(java.util.logging.Level.WARNING); Logger sunlogger = Logger.getLogger("com.sun.xml.ws.model"); sunlogger.setLevel(Level.WARNING); java.util.logging.Logger.getLogger( com.sun.xml.ws.util.Constants.LoggingDomain).setLevel(java.util.logging.Level.WARNING); /* Lots of info please: */ java.util.logging.Logger.getAnonymousLogger().setLevel(java.util.logging.Level.FINEST); java.util.logging.Logger.getLogger( com.sun.xml.ws.util.Constants.LoggingDomain).setLevel(java.util.logging.Level.FINEST); // TODO See https://jax-ws.dev.java.net/guide/Logging.html for info on more logging to set up. //System.setProperty("com.sun.xml.ws.transport.local.LocalTransportPipe.dump","true"); //System.setProperty("com.sun.xml.ws.util.pipe.StandaloneTubeAssembler.dump","true"); //System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump","true"); // Doing this KILLS STREAMING. Log that. //System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump","true"); URL wsdl; try { wsdl = new URL( args[0] ); } catch (MalformedURLException e) { e.printStackTrace(); return; } PlanetsServiceExplorer pse = new PlanetsServiceExplorer( wsdl ); System.out.println(".describe(): "+pse.getServiceDescription()); Service service = Service.create(wsdl, pse.getQName()); //service.addPort(portName, SOAPBinding.SOAP11HTTP_MTOM_BINDING, endpointAddress) PlanetsService ps = (PlanetsService) service.getPort(pse.getServiceClass()); // TODO The client wrapper code should enforce this stuff: SOAPBinding binding = (SOAPBinding)((BindingProvider)ps).getBinding(); System.out.println("Logging MTOM="+binding.isMTOMEnabled()); ((BindingProvider)ps).getRequestContext().put( JAXWSProperties.MTOM_THRESHOLOD_VALUE, 8192); ((BindingProvider)ps).getRequestContext().put( JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192); System.out.println("Logging MTOM="+binding.isMTOMEnabled()); binding.setMTOMEnabled(true); System.out.println("Logging MTOM="+binding.isMTOMEnabled()); //System.out.println("Logging MTOM="+((BindingProvider)ps).getBinding().getBindingID()+" v. "+SOAPBinding.SOAP11HTTP_MTOM_BINDING); /* * The different services are invoked in different ways... */ if( pse.getQName().equals( Migrate.QNAME ) ) { System.out.println("Is a Migrate service. "); Migrate s = MigrateWrapper.createWrapper(wsdl); DigitalObject dobIn = new DigitalObject.Builder(Content.byReference( new File(args[1]))).build(); MigrateResult result = s.migrate(dobIn, URI.create(args[2]), URI.create(args[3]), null); System.out.println("ServiceReport: "+result.getReport()); DigitalObjectUtils.toFile( result.getDigitalObject(), new File("output" ) ); } else if( pse.getQName().equals( Identify.QNAME ) ) { System.out.println("Is an Identify service. "); Identify s = new IdentifyWrapper(wsdl); DigitalObject dobIn = new DigitalObject.Builder(Content.byReference( new File(args[1]))).build(); IdentifyResult result = s.identify(dobIn, null); System.out.println("ServiceReport: "+result.getReport()); } }
1028034_0
public Vector getDirectionY() { return directionY; }
1028034_1
public Vector getDirectionY() { return directionY; }
1028034_2
public Point3D getPoint(double x, double y) { Point3D p = new Point3D(); p.setX(this.base.getX() + (this.directionX.getX() * x) + (this.directionY.getX() * y)); p.setY(this.base.getY() + (this.directionX.getY() * x) + (this.directionY.getY() * y)); p.setZ(this.base.getZ() + (this.directionX.getZ() * x) + (this.directionY.getZ() * y)); return p; }
1028034_3
public double[] getParameter(Point3D p) { double u = 0.0; double v = (this.directionX.getY() * this.directionY.getX()) - (this.directionX.getX() * this.directionY.getY()); if (v != 0.0) { v = ((p.getY() * this.directionY.getX()) - (this.base.getY() * this.directionY.getX()) - (this.directionY.getY() * p.getX()) + (this.base.getX() * this.directionY.getY())) / v; } if (this.directionY.getX() != 0.0) { u = (p.getX() - this.base.getX() - (this.directionX.getX() * v)) / this.directionY.getX(); } else if (this.directionY.getY() != 0.0) { u = (p.getY() - this.base.getY() - (this.directionX.getY() * v)) / this.directionY.getY(); } else if (this.directionY.getY() != 0.0) { u = (p.getZ() - this.base.getZ() - (this.directionX.getZ() * v)) / this.directionY.getZ(); } return new double[] { v, u }; }
1028034_4
public boolean isOnPlane(Point3D p) { double[] para = this.getParameter(p); double v = this.base.getZ() + (this.directionX.getZ() * para[0]) + (this.directionY.getZ() * para[1]); if (!(Math.abs((p.getZ() - v)) < MathUtils.DISTANCE_DELTA)) { return false; } v = this.base.getY() + (this.directionX.getY() * para[0]) + (this.directionY.getY() * para[1]); if (!(Math.abs((p.getY() - v)) < MathUtils.DISTANCE_DELTA)) { return false; } v = this.base.getX() + (this.directionX.getX() * para[0]) + (this.directionY.getX() * para[1]); if (!(Math.abs((p.getX() - v)) < MathUtils.DISTANCE_DELTA)) { return false; } return true; }
1028034_5
public boolean isOnPlane(Point3D p) { double[] para = this.getParameter(p); double v = this.base.getZ() + (this.directionX.getZ() * para[0]) + (this.directionY.getZ() * para[1]); if (!(Math.abs((p.getZ() - v)) < MathUtils.DISTANCE_DELTA)) { return false; } v = this.base.getY() + (this.directionX.getY() * para[0]) + (this.directionY.getY() * para[1]); if (!(Math.abs((p.getY() - v)) < MathUtils.DISTANCE_DELTA)) { return false; } v = this.base.getX() + (this.directionX.getX() * para[0]) + (this.directionY.getX() * para[1]); if (!(Math.abs((p.getX() - v)) < MathUtils.DISTANCE_DELTA)) { return false; } return true; }
1028034_6
public Vector getNormal() { return normal; }
1028034_7
public double[] getBasicFunctions(int i, double u) { double[] n = new double[degree + 1]; n[0] = 1.0; double[] left = new double[degree + 1]; double[] right = new double[degree + 1]; for (int j = 1; j <= degree; j++) { left[j] = u - this.knots[(i + 1) - j]; right[j] = this.knots[i + j] - u; double saved = 0.0; for (int r = 0; r < j; r++) { double t = n[r] / (right[r + 1] + left[j - r]); n[r] = saved + (right[r + 1] * t); saved = left[j - r] * t; } n[j] = saved; } return n; }
103035_10
public String getDomain() { return domain; }
103035_11
public static MBeanServer getMBeanServer() { return mbs; }
103035_12
public void setDomain(String domain) { JMXFactory.domain = domain; }
103035_13
public IClient newClient(Object[] params) throws ClientNotFoundException, ClientRejectedException { String id = nextId(); IClient client = new Client(id, this); addClient(id, client); return client; }
103035_14
protected void addClient(IClient client) { addClient(client.getId(), client); }
103035_15
public IClient lookupClient(String id) throws ClientNotFoundException { return getClient(id); }
103035_16
public Client getClient(String id) throws ClientNotFoundException { final Client result = (Client) clients.get(id); if (result == null) { throw new ClientNotFoundException(id); } return result; }
103035_17
public ClientList<Client> getClientList() { ClientList<Client> list = new ClientList<Client>(); for (IClient c : clients.values()) { list.add((Client) c); } return list; }
103035_18
@SuppressWarnings("unchecked") protected Collection<IClient> getClients() { if (!hasClients()) { // Avoid creating new Collection object if no clients exist. return Collections.EMPTY_SET; } return Collections.unmodifiableCollection(clients.values()); }
103035_19
protected void removeClient(IClient client) { clients.remove(client.getId()); }
103035_20
public static Object convert(Object source, Class<?> target) throws ConversionException { if (target == null) { throw new ConversionException("Unable to perform conversion, target was null"); } if (source == null) { if (target.isPrimitive()) { throw new ConversionException(String.format("Unable to convert null to primitive value of %s", target)); } return source; } else if ((source instanceof Float && ((Float) source).isNaN()) || (source instanceof Double && ((Double) source).isNaN())) { // Don't convert NaN values return source; } if (IConnection.class.isAssignableFrom(source.getClass()) && !target.equals(IConnection.class)) { throw new ConversionException("IConnection must match exactly"); } if (target.isInstance(source)) { return source; } if (target.isAssignableFrom(source.getClass())) { return source; } if (target.isArray()) { return convertToArray(source, target); } if (target.equals(String.class)) { return source.toString(); } if (target.isPrimitive()) { return convertToWrappedPrimitive(source, primitiveMap.get(target)); } if (wrapperMap.containsKey(target)) { return convertToWrappedPrimitive(source, target); } if (target.equals(Map.class)) { return convertBeanToMap(source); } if (target.equals(List.class) || target.equals(Collection.class)) { if (source.getClass().equals(LinkedHashMap.class)) { return convertMapToList((LinkedHashMap<?, ?>) source); } else if (source.getClass().isArray()) { return convertArrayToList((Object[]) source); } } if (target.equals(Set.class) && source.getClass().isArray()) { return convertArrayToSet((Object[]) source); } throw new ConversionException(String.format("Unable to preform conversion from %s to %s", source, target)); }
103035_21
public static Object convert(Object source, Class<?> target) throws ConversionException { if (target == null) { throw new ConversionException("Unable to perform conversion, target was null"); } if (source == null) { if (target.isPrimitive()) { throw new ConversionException(String.format("Unable to convert null to primitive value of %s", target)); } return source; } else if ((source instanceof Float && ((Float) source).isNaN()) || (source instanceof Double && ((Double) source).isNaN())) { // Don't convert NaN values return source; } if (IConnection.class.isAssignableFrom(source.getClass()) && !target.equals(IConnection.class)) { throw new ConversionException("IConnection must match exactly"); } if (target.isInstance(source)) { return source; } if (target.isAssignableFrom(source.getClass())) { return source; } if (target.isArray()) { return convertToArray(source, target); } if (target.equals(String.class)) { return source.toString(); } if (target.isPrimitive()) { return convertToWrappedPrimitive(source, primitiveMap.get(target)); } if (wrapperMap.containsKey(target)) { return convertToWrappedPrimitive(source, target); } if (target.equals(Map.class)) { return convertBeanToMap(source); } if (target.equals(List.class) || target.equals(Collection.class)) { if (source.getClass().equals(LinkedHashMap.class)) { return convertMapToList((LinkedHashMap<?, ?>) source); } else if (source.getClass().isArray()) { return convertArrayToList((Object[]) source); } } if (target.equals(Set.class) && source.getClass().isArray()) { return convertArrayToSet((Object[]) source); } throw new ConversionException(String.format("Unable to preform conversion from %s to %s", source, target)); }
103035_22
public static Object convert(Object source, Class<?> target) throws ConversionException { if (target == null) { throw new ConversionException("Unable to perform conversion, target was null"); } if (source == null) { if (target.isPrimitive()) { throw new ConversionException(String.format("Unable to convert null to primitive value of %s", target)); } return source; } else if ((source instanceof Float && ((Float) source).isNaN()) || (source instanceof Double && ((Double) source).isNaN())) { // Don't convert NaN values return source; } if (IConnection.class.isAssignableFrom(source.getClass()) && !target.equals(IConnection.class)) { throw new ConversionException("IConnection must match exactly"); } if (target.isInstance(source)) { return source; } if (target.isAssignableFrom(source.getClass())) { return source; } if (target.isArray()) { return convertToArray(source, target); } if (target.equals(String.class)) { return source.toString(); } if (target.isPrimitive()) { return convertToWrappedPrimitive(source, primitiveMap.get(target)); } if (wrapperMap.containsKey(target)) { return convertToWrappedPrimitive(source, target); } if (target.equals(Map.class)) { return convertBeanToMap(source); } if (target.equals(List.class) || target.equals(Collection.class)) { if (source.getClass().equals(LinkedHashMap.class)) { return convertMapToList((LinkedHashMap<?, ?>) source); } else if (source.getClass().isArray()) { return convertArrayToList((Object[]) source); } } if (target.equals(Set.class) && source.getClass().isArray()) { return convertArrayToSet((Object[]) source); } throw new ConversionException(String.format("Unable to preform conversion from %s to %s", source, target)); }
103035_23
public static Object convert(Object source, Class<?> target) throws ConversionException { if (target == null) { throw new ConversionException("Unable to perform conversion, target was null"); } if (source == null) { if (target.isPrimitive()) { throw new ConversionException(String.format("Unable to convert null to primitive value of %s", target)); } return source; } else if ((source instanceof Float && ((Float) source).isNaN()) || (source instanceof Double && ((Double) source).isNaN())) { // Don't convert NaN values return source; } if (IConnection.class.isAssignableFrom(source.getClass()) && !target.equals(IConnection.class)) { throw new ConversionException("IConnection must match exactly"); } if (target.isInstance(source)) { return source; } if (target.isAssignableFrom(source.getClass())) { return source; } if (target.isArray()) { return convertToArray(source, target); } if (target.equals(String.class)) { return source.toString(); } if (target.isPrimitive()) { return convertToWrappedPrimitive(source, primitiveMap.get(target)); } if (wrapperMap.containsKey(target)) { return convertToWrappedPrimitive(source, target); } if (target.equals(Map.class)) { return convertBeanToMap(source); } if (target.equals(List.class) || target.equals(Collection.class)) { if (source.getClass().equals(LinkedHashMap.class)) { return convertMapToList((LinkedHashMap<?, ?>) source); } else if (source.getClass().isArray()) { return convertArrayToList((Object[]) source); } } if (target.equals(Set.class) && source.getClass().isArray()) { return convertArrayToSet((Object[]) source); } throw new ConversionException(String.format("Unable to preform conversion from %s to %s", source, target)); }
103035_24
public static Object convert(Object source, Class<?> target) throws ConversionException { if (target == null) { throw new ConversionException("Unable to perform conversion, target was null"); } if (source == null) { if (target.isPrimitive()) { throw new ConversionException(String.format("Unable to convert null to primitive value of %s", target)); } return source; } else if ((source instanceof Float && ((Float) source).isNaN()) || (source instanceof Double && ((Double) source).isNaN())) { // Don't convert NaN values return source; } if (IConnection.class.isAssignableFrom(source.getClass()) && !target.equals(IConnection.class)) { throw new ConversionException("IConnection must match exactly"); } if (target.isInstance(source)) { return source; } if (target.isAssignableFrom(source.getClass())) { return source; } if (target.isArray()) { return convertToArray(source, target); } if (target.equals(String.class)) { return source.toString(); } if (target.isPrimitive()) { return convertToWrappedPrimitive(source, primitiveMap.get(target)); } if (wrapperMap.containsKey(target)) { return convertToWrappedPrimitive(source, target); } if (target.equals(Map.class)) { return convertBeanToMap(source); } if (target.equals(List.class) || target.equals(Collection.class)) { if (source.getClass().equals(LinkedHashMap.class)) { return convertMapToList((LinkedHashMap<?, ?>) source); } else if (source.getClass().isArray()) { return convertArrayToList((Object[]) source); } } if (target.equals(Set.class) && source.getClass().isArray()) { return convertArrayToSet((Object[]) source); } throw new ConversionException(String.format("Unable to preform conversion from %s to %s", source, target)); }
103035_25
public static Object convert(Object source, Class<?> target) throws ConversionException { if (target == null) { throw new ConversionException("Unable to perform conversion, target was null"); } if (source == null) { if (target.isPrimitive()) { throw new ConversionException(String.format("Unable to convert null to primitive value of %s", target)); } return source; } else if ((source instanceof Float && ((Float) source).isNaN()) || (source instanceof Double && ((Double) source).isNaN())) { // Don't convert NaN values return source; } if (IConnection.class.isAssignableFrom(source.getClass()) && !target.equals(IConnection.class)) { throw new ConversionException("IConnection must match exactly"); } if (target.isInstance(source)) { return source; } if (target.isAssignableFrom(source.getClass())) { return source; } if (target.isArray()) { return convertToArray(source, target); } if (target.equals(String.class)) { return source.toString(); } if (target.isPrimitive()) { return convertToWrappedPrimitive(source, primitiveMap.get(target)); } if (wrapperMap.containsKey(target)) { return convertToWrappedPrimitive(source, target); } if (target.equals(Map.class)) { return convertBeanToMap(source); } if (target.equals(List.class) || target.equals(Collection.class)) { if (source.getClass().equals(LinkedHashMap.class)) { return convertMapToList((LinkedHashMap<?, ?>) source); } else if (source.getClass().isArray()) { return convertArrayToList((Object[]) source); } } if (target.equals(Set.class) && source.getClass().isArray()) { return convertArrayToSet((Object[]) source); } throw new ConversionException(String.format("Unable to preform conversion from %s to %s", source, target)); }
103035_26
public static Object convert(Object source, Class<?> target) throws ConversionException { if (target == null) { throw new ConversionException("Unable to perform conversion, target was null"); } if (source == null) { if (target.isPrimitive()) { throw new ConversionException(String.format("Unable to convert null to primitive value of %s", target)); } return source; } else if ((source instanceof Float && ((Float) source).isNaN()) || (source instanceof Double && ((Double) source).isNaN())) { // Don't convert NaN values return source; } if (IConnection.class.isAssignableFrom(source.getClass()) && !target.equals(IConnection.class)) { throw new ConversionException("IConnection must match exactly"); } if (target.isInstance(source)) { return source; } if (target.isAssignableFrom(source.getClass())) { return source; } if (target.isArray()) { return convertToArray(source, target); } if (target.equals(String.class)) { return source.toString(); } if (target.isPrimitive()) { return convertToWrappedPrimitive(source, primitiveMap.get(target)); } if (wrapperMap.containsKey(target)) { return convertToWrappedPrimitive(source, target); } if (target.equals(Map.class)) { return convertBeanToMap(source); } if (target.equals(List.class) || target.equals(Collection.class)) { if (source.getClass().equals(LinkedHashMap.class)) { return convertMapToList((LinkedHashMap<?, ?>) source); } else if (source.getClass().isArray()) { return convertArrayToList((Object[]) source); } } if (target.equals(Set.class) && source.getClass().isArray()) { return convertArrayToSet((Object[]) source); } throw new ConversionException(String.format("Unable to preform conversion from %s to %s", source, target)); }
103035_27
public static IServerStream createServerStream(IScope scope, String name) { logger.debug("Creating server stream: {} scope: {}", name, scope); ServerStream stream = new ServerStream(); stream.setScope(scope); stream.setName(name); stream.setPublishedName(name); //save to the list for later lookups String key = scope.getName() + '/' + name; serverStreamMap.put(key, stream); return stream; }
103035_28
public static IServerStream getServerStream(IScope scope, String name) { logger.debug("Looking up server stream: {} scope: {}", name, scope); String key = scope.getName() + '/' + name; if (serverStreamMap.containsKey(key)) { return serverStreamMap.get(key); } else { logger.warn("Server stream not found with key: {}", key); return null; } }
103035_29
public ScheduledThreadPoolExecutor getExecutor() { if (executor == null) { log.warn("ScheduledThreadPoolExecutor was null on request"); } return executor; }
103035_30
public void start() { //ensure the play engine exists if (engine == null) { IScope scope = getScope(); if (scope != null) { IContext ctx = scope.getContext(); ISchedulingService schedulingService = (ISchedulingService) ctx.getBean(ISchedulingService.BEAN_NAME); IConsumerService consumerService = (IConsumerService) ctx.getBean(IConsumerService.KEY); IProviderService providerService = (IProviderService) ctx.getBean(IProviderService.BEAN_NAME); engine = new PlayEngine.Builder(this, schedulingService, consumerService, providerService).build(); } else { log.info("Scope was null on start"); } } // Create bw control service from Spring bean factory // and register myself // XXX Bandwidth control service should not be bound to // a specific scope because it's designed to control // the bandwidth system-wide. if (bwController == null) { bwController = (IBWControlService) getScope().getContext().getBean(IBWControlService.KEY); } bwContext = bwController.registerBWControllable(this); //set bandwidth members on the engine engine.setBandwidthController(bwController, bwContext); //set buffer check interval engine.setBufferCheckInterval(bufferCheckInterval); //set underrun trigger engine.setUnderrunTrigger(underrunTrigger); // Start playback engine engine.start(); // Notify subscribers on start notifySubscriberStart(); }
103035_31
public void play() throws IOException { // Check how many is yet to play... int count = items.size(); // Return if playlist is empty if (count == 0) { return; } // Move to next if current item is set to -1 if (currentItemIndex == -1) { moveToNext(); } // If there's some more items on list then play current item while (count-- > 0) { IPlayItem item = null; read.lock(); try { // Get playlist item item = items.get(currentItemIndex); engine.play(item); break; } catch (StreamNotFoundException e) { // go for next item moveToNext(); if (currentItemIndex == -1) { // we reaches the end. break; } item = items.get(currentItemIndex); } catch (IllegalStateException e) { // an stream is already playing break; } finally { read.unlock(); } } }
103035_32
public void pause(int position) { try { engine.pause(position); } catch (IllegalStateException e) { log.debug("pause caught an IllegalStateException"); } }
103035_33
public void resume(int position) { try { engine.resume(position); } catch (IllegalStateException e) { log.debug("resume caught an IllegalStateException"); } }
103035_34
public void seek(int position) throws OperationNotSupportedException { try { engine.seek(position); } catch (IllegalStateException e) { log.debug("seek caught an IllegalStateException"); } }
103035_35
public void addItem(IPlayItem item) { write.lock(); try { items.add(item); } finally { write.unlock(); } }
103035_36
public void previousItem() { stop(); moveToPrevious(); if (currentItemIndex == -1) { return; } IPlayItem item = null; int count = items.size(); while (count-- > 0) { read.lock(); try { item = items.get(currentItemIndex); engine.play(item); break; } catch (IOException err) { log.error("Error while starting to play item, moving to previous.", err); // go for next item moveToPrevious(); if (currentItemIndex == -1) { // we reaches the end. break; } } catch (StreamNotFoundException e) { // go for next item moveToPrevious(); if (currentItemIndex == -1) { // we reaches the end. break; } } catch (IllegalStateException e) { // an stream is already playing break; } finally { read.unlock(); } } }
103035_37
public void nextItem() { moveToNext(); if (currentItemIndex == -1) { return; } IPlayItem item = null; int count = items.size(); while (count-- > 0) { read.lock(); try { item = items.get(currentItemIndex); engine.play(item, false); break; } catch (IOException err) { log.error("Error while starting to play item, moving to next", err); // go for next item moveToNext(); if (currentItemIndex == -1) { // we reaches the end. break; } } catch (StreamNotFoundException e) { // go for next item moveToNext(); if (currentItemIndex == -1) { // we reaches the end. break; } } catch (IllegalStateException e) { // an stream is already playing break; } finally { read.unlock(); } } }
103035_38
public void setItem(int index) { if (index < 0 || index >= items.size()) { return; } stop(); currentItemIndex = index; read.lock(); try { IPlayItem item = items.get(currentItemIndex); engine.play(item); } catch (IOException e) { log.error("setItem caught a IOException", e); } catch (StreamNotFoundException e) { // let the engine retain the STOPPED state // and wait for control from outside log.debug("setItem caught a StreamNotFoundException"); } catch (IllegalStateException e) { log.error("Illegal state exception on playlist item setup", e); } finally { read.unlock(); } }
103035_39
public void stop() { try { engine.stop(); } catch (IllegalStateException e) { log.debug("stop caught an IllegalStateException"); } }
103035_40
public void close() { engine.close(); // unregister myself from bandwidth controller bwController.unregisterBWControllable(bwContext); notifySubscriberClose(); }
103035_41
public Scope() { this(null); }
103035_42
public Properties getMergedProperties() { return mergedProperties; }
103035_43
public Properties getMergedProperties() { return mergedProperties; }
103035_44
public Properties getMergedProperties() { return mergedProperties; }
1031515_0
public Lookup createLookup(List<String> keys) { return new LookupImpl(keys); }
1031515_1
public Lookup createLookup(List<String> keys) { return new LookupImpl(keys); }
1050944_0
public T get() { return value; }
1050944_1
public static <T> Collection<T> load(Class<T> contract, ClassLoader... loaders) { Map<String, T> services = new LinkedHashMap<>(); if (loaders.length == 0) { try { ServiceLoader<T> loadedServices = ServiceLoader.load(contract); addServices(loadedServices, services); } catch (Exception e) { // Ignore } } else { for (ClassLoader loader : loaders) { if (loader == null) throw new NullPointerException(); try { ServiceLoader<T> loadedServices = ServiceLoader.load(contract, loader); addServices(loadedServices, services); } catch (Exception e) { // Ignore } } } if (services.isEmpty()) { LOG.debugf("No service impls found: %s", contract.getSimpleName()); } return services.values(); }
1050944_2
@Override public int size() { return 0; }
1050944_3
@Override public boolean isEmpty() { return true; }
1050944_4
@Override public boolean contains(int i) { return false; }
1050944_5
@Override public boolean contains(int i) { return false; }
1050944_6
@Override public PrimitiveIterator.OfInt iterator() { return EmptyIntIterator.INSTANCE; }
1050944_7
@Override public Object[] toArray() { return new Object[0]; }
1050944_8
@Override public Object[] toArray() { return new Object[0]; }
1050944_9
@Override public boolean containsAll(IntSet set) { return set.isEmpty(); }
1052717_0
static <X> void ensureNoConflictingAnnotationsPresentOn(final Class<X> type) throws ResolutionException { final Set<Field> fieldsHavingConflictingAnnotations = new HashSet<Field>(); for (final Field fieldToInspect : allFieldsAndSuperclassFieldsIn(type)) { if (isAnnotatedWithOneOf(fieldToInspect, CAMEL) && isAnnotatedWithOneOf(fieldToInspect, CDI_CONFLICTS)) { fieldsHavingConflictingAnnotations.add(fieldToInspect); } } if (!fieldsHavingConflictingAnnotations.isEmpty()) { final String error = buildErrorMessageFrom(fieldsHavingConflictingAnnotations); throw new ResolutionException(error); } }
1052717_1
static <X> void ensureNoConflictingAnnotationsPresentOn(final Class<X> type) throws ResolutionException { final Set<Field> fieldsHavingConflictingAnnotations = new HashSet<Field>(); for (final Field fieldToInspect : allFieldsAndSuperclassFieldsIn(type)) { if (isAnnotatedWithOneOf(fieldToInspect, CAMEL) && isAnnotatedWithOneOf(fieldToInspect, CDI_CONFLICTS)) { fieldsHavingConflictingAnnotations.add(fieldToInspect); } } if (!fieldsHavingConflictingAnnotations.isEmpty()) { final String error = buildErrorMessageFrom(fieldsHavingConflictingAnnotations); throw new ResolutionException(error); } }
1052717_2
static <X> boolean hasCamelInjectAnnotatedFields(final Class<X> type) { return !camelInjectAnnotatedFieldsIn(type).isEmpty(); }
1052717_3
static <X> boolean hasCamelInjectAnnotatedFields(final Class<X> type) { return !camelInjectAnnotatedFieldsIn(type).isEmpty(); }
1052717_4
static <X> Set<Field> camelInjectAnnotatedFieldsIn(final Class<X> type) { final Set<Field> camelInjectAnnotatedFields = new HashSet<Field>(); for (final Field fieldToInspect : allFieldsAndSuperclassFieldsIn(type)) { if (isAnnotatedWithOneOf(fieldToInspect, CAMEL)) { camelInjectAnnotatedFields.add(fieldToInspect); } } return Collections.unmodifiableSet(camelInjectAnnotatedFields); }
1057490_0
public byte[] getL() { if (lengthSize > 0) return getLengthArray(); if (value == null) return new byte[1]; // if Length is less than 128 // set the 8bit as 0 indicating next 7 bits is the length // of the message // if length is more than 127 then, set the first bit as 1 indicating // next 7 bits will indicate the length of following bytes used for // length BigInteger bi = BigInteger.valueOf(value.length); /* Value to be encoded on multiple bytes */ byte[] rBytes = bi.toByteArray(); /* If value can be encoded on one byte */ if (value.length < 0x80) return rBytes; //we need 1 byte to indicate the length //for that is used sign byte (first 8-bits equals 0), //if it is not present it is added if (rBytes[0] > 0) rBytes = ISOUtil.concat(new byte[1], rBytes); rBytes[0] = (byte) (0x80 | rBytes.length - 1); return rBytes; }
1057490_1
public byte[] getL() { if (lengthSize > 0) return getLengthArray(); if (value == null) return new byte[1]; // if Length is less than 128 // set the 8bit as 0 indicating next 7 bits is the length // of the message // if length is more than 127 then, set the first bit as 1 indicating // next 7 bits will indicate the length of following bytes used for // length BigInteger bi = BigInteger.valueOf(value.length); /* Value to be encoded on multiple bytes */ byte[] rBytes = bi.toByteArray(); /* If value can be encoded on one byte */ if (value.length < 0x80) return rBytes; //we need 1 byte to indicate the length //for that is used sign byte (first 8-bits equals 0), //if it is not present it is added if (rBytes[0] > 0) rBytes = ISOUtil.concat(new byte[1], rBytes); rBytes[0] = (byte) (0x80 | rBytes.length - 1); return rBytes; }
1057490_2
public byte[] getL() { if (lengthSize > 0) return getLengthArray(); if (value == null) return new byte[1]; // if Length is less than 128 // set the 8bit as 0 indicating next 7 bits is the length // of the message // if length is more than 127 then, set the first bit as 1 indicating // next 7 bits will indicate the length of following bytes used for // length BigInteger bi = BigInteger.valueOf(value.length); /* Value to be encoded on multiple bytes */ byte[] rBytes = bi.toByteArray(); /* If value can be encoded on one byte */ if (value.length < 0x80) return rBytes; //we need 1 byte to indicate the length //for that is used sign byte (first 8-bits equals 0), //if it is not present it is added if (rBytes[0] > 0) rBytes = ISOUtil.concat(new byte[1], rBytes); rBytes[0] = (byte) (0x80 | rBytes.length - 1); return rBytes; }
1057490_3
public byte[] getL() { if (lengthSize > 0) return getLengthArray(); if (value == null) return new byte[1]; // if Length is less than 128 // set the 8bit as 0 indicating next 7 bits is the length // of the message // if length is more than 127 then, set the first bit as 1 indicating // next 7 bits will indicate the length of following bytes used for // length BigInteger bi = BigInteger.valueOf(value.length); /* Value to be encoded on multiple bytes */ byte[] rBytes = bi.toByteArray(); /* If value can be encoded on one byte */ if (value.length < 0x80) return rBytes; //we need 1 byte to indicate the length //for that is used sign byte (first 8-bits equals 0), //if it is not present it is added if (rBytes[0] > 0) rBytes = ISOUtil.concat(new byte[1], rBytes); rBytes[0] = (byte) (0x80 | rBytes.length - 1); return rBytes; }
1057490_4
public byte[] getL() { if (lengthSize > 0) return getLengthArray(); if (value == null) return new byte[1]; // if Length is less than 128 // set the 8bit as 0 indicating next 7 bits is the length // of the message // if length is more than 127 then, set the first bit as 1 indicating // next 7 bits will indicate the length of following bytes used for // length BigInteger bi = BigInteger.valueOf(value.length); /* Value to be encoded on multiple bytes */ byte[] rBytes = bi.toByteArray(); /* If value can be encoded on one byte */ if (value.length < 0x80) return rBytes; //we need 1 byte to indicate the length //for that is used sign byte (first 8-bits equals 0), //if it is not present it is added if (rBytes[0] > 0) rBytes = ISOUtil.concat(new byte[1], rBytes); rBytes[0] = (byte) (0x80 | rBytes.length - 1); return rBytes; }
1057490_5
public byte[] getL() { if (lengthSize > 0) return getLengthArray(); if (value == null) return new byte[1]; // if Length is less than 128 // set the 8bit as 0 indicating next 7 bits is the length // of the message // if length is more than 127 then, set the first bit as 1 indicating // next 7 bits will indicate the length of following bytes used for // length BigInteger bi = BigInteger.valueOf(value.length); /* Value to be encoded on multiple bytes */ byte[] rBytes = bi.toByteArray(); /* If value can be encoded on one byte */ if (value.length < 0x80) return rBytes; //we need 1 byte to indicate the length //for that is used sign byte (first 8-bits equals 0), //if it is not present it is added if (rBytes[0] > 0) rBytes = ISOUtil.concat(new byte[1], rBytes); rBytes[0] = (byte) (0x80 | rBytes.length - 1); return rBytes; }
1057490_6
public byte[] getL() { if (lengthSize > 0) return getLengthArray(); if (value == null) return new byte[1]; // if Length is less than 128 // set the 8bit as 0 indicating next 7 bits is the length // of the message // if length is more than 127 then, set the first bit as 1 indicating // next 7 bits will indicate the length of following bytes used for // length BigInteger bi = BigInteger.valueOf(value.length); /* Value to be encoded on multiple bytes */ byte[] rBytes = bi.toByteArray(); /* If value can be encoded on one byte */ if (value.length < 0x80) return rBytes; //we need 1 byte to indicate the length //for that is used sign byte (first 8-bits equals 0), //if it is not present it is added if (rBytes[0] > 0) rBytes = ISOUtil.concat(new byte[1], rBytes); rBytes[0] = (byte) (0x80 | rBytes.length - 1); return rBytes; }
1057490_7
public byte[] getTLV() { String hexTag = Integer.toHexString(tag); byte[] bTag = ISOUtil.hex2byte(hexTag); if (tagSize > 0) bTag = fitInArray(bTag, tagSize); byte[] bLen = getL(); byte[] bVal = getValue(); if (bVal == null) //Value can be null bVal = new byte[0]; int tLength = bTag.length + bLen.length + bVal.length; byte[] out = new byte[tLength]; System.arraycopy(bTag, 0, out, 0, bTag.length); System.arraycopy(bLen, 0, out, bTag.length, bLen.length); System.arraycopy(bVal, 0, out, bTag.length + bLen.length, bVal.length ); return out; }
1057490_8
public byte[] getTLV() { String hexTag = Integer.toHexString(tag); byte[] bTag = ISOUtil.hex2byte(hexTag); if (tagSize > 0) bTag = fitInArray(bTag, tagSize); byte[] bLen = getL(); byte[] bVal = getValue(); if (bVal == null) //Value can be null bVal = new byte[0]; int tLength = bTag.length + bLen.length + bVal.length; byte[] out = new byte[tLength]; System.arraycopy(bTag, 0, out, 0, bTag.length); System.arraycopy(bLen, 0, out, bTag.length, bLen.length); System.arraycopy(bVal, 0, out, bTag.length + bLen.length, bVal.length ); return out; }
1057490_9
public byte[] getTLV() { String hexTag = Integer.toHexString(tag); byte[] bTag = ISOUtil.hex2byte(hexTag); if (tagSize > 0) bTag = fitInArray(bTag, tagSize); byte[] bLen = getL(); byte[] bVal = getValue(); if (bVal == null) //Value can be null bVal = new byte[0]; int tLength = bTag.length + bLen.length + bVal.length; byte[] out = new byte[tLength]; System.arraycopy(bTag, 0, out, 0, bTag.length); System.arraycopy(bLen, 0, out, bTag.length, bLen.length); System.arraycopy(bVal, 0, out, bTag.length + bLen.length, bVal.length ); return out; }
1068402_0
public static void initialize(KeyStore... keyStores) throws Exception { TrustManager[] trustManagers = new TrustManager[] { new AggregateTrustManager(keyStores) }; SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustManagers, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); }
1068402_1
public static void initialize(KeyStore... keyStores) throws Exception { TrustManager[] trustManagers = new TrustManager[] { new AggregateTrustManager(keyStores) }; SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustManagers, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); }
1068402_2
public void clearAll() { v.clear(); }
1068402_3
public Vector getValues() { return (Vector)v.clone(); }
1068402_4
public void setValues(Iterable<Double> vals) { if(vals==null) throw new IllegalArgumentException("vector is null"); v.clear(); for(Double d : vals) v.add(d); }
1068402_5
public void removeValue(int location) { if(location < v.size() && location >= 0) v.removeElementAt(location); }
1068402_6
public int getPort() { if (server == null) { return port; } return ((ServerConnector)server.getConnectors()[0]).getLocalPort(); }
1068402_7
public int getPort() { if (server == null) { return port; } return ((ServerConnector)server.getConnectors()[0]).getLocalPort(); }
1068402_8
@Override public void start() throws Exception { createServer(); ServerConnector connector = new ServerConnector(server); connector.setPort(port); String address = HostUtil.getHostAddressFromProperty("java.rmi.server.hostname"); connector.setHost(address); server.setConnectors(new Connector[] { connector }); //server.setHandler(contexts); server.setHandler(handlers); server.start(); setProperty(); }
1068402_9
public static Settings getSettings() throws SettingsBuildingException { DefaultSettingsBuilder defaultSettingsBuilder = new DefaultSettingsBuilder(); DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); File userSettingsFile = new File(System.getProperty("user.home"), ".m2" + File.separator + "settings.xml"); request.setUserSettingsFile(userSettingsFile); defaultSettingsBuilder.setSettingsWriter(new DefaultSettingsWriter()); defaultSettingsBuilder.setSettingsReader(new DefaultSettingsReader()); defaultSettingsBuilder.setSettingsValidator(new DefaultSettingsValidator()); SettingsBuildingResult build = defaultSettingsBuilder.build(request); return build.getEffectiveSettings(); }
1071043_0
@Override public QuestionSet processDocument( Document doc ) throws ParseException { Element root = doc.getRootElement(); if ( !root.getName().equalsIgnoreCase( "QuestionSet" ) ) throw new ParseException( "QuestionSet: Root not <QuestionSet>", 0 ); // Check version number String versionString = root.getAttributeValue( "version" ); if ( versionString == null ) { LOGGER.warning( "No `version' attribute on <QuestionSet> element" ); } else { try { int version = Integer.parseInt( versionString ); if ( version == 1 || version == 2 || version == 3 ) { LOGGER.warning( "QuestionSet version " + version + " is no longer " + "supported: proceeding anyway, but errors may be present." ); } else if ( version == 4 ) { // Supported, do nothing } else { // Unsupported, give warning LOGGER.warning( "QuestionSet format version (" + version + ") is newer than this software and may not be handled correctly." ); } } catch ( NumberFormatException e ) { LOGGER.log( Level.WARNING, "Cannot parse version number: " + versionString, e ); } } List<?> topElements = root.getChildren(); // Loop over the top-level elements String name = null; String description = null; int recommendedTimePerQuestion = -1; String category = ""; List<Question> questions = new ArrayList<Question>(); for ( Object object : topElements ) { Element topElement = (Element) object; String tagName = topElement.getName(); if ( tagName.equalsIgnoreCase( "Name" ) ) { name = topElement.getText(); } else if ( tagName.equalsIgnoreCase( "Description" ) ) { description = topElement.getText(); } else if ( tagName.equalsIgnoreCase( "RecommendedTimePerQuestion" ) ) { recommendedTimePerQuestion = Integer.parseInt( topElement.getText() ); } else if ( tagName.equalsIgnoreCase( "Category" ) ) { category = topElement.getText(); } else if ( tagName.equalsIgnoreCase( "Questions" ) ) { // Loop over each question for ( Object object2 : topElement.getChildren() ) { Element questionElement = (Element) object2; String name2 = questionElement.getName(); try { if ( name2.equalsIgnoreCase( "MultipleChoiceQuestion" ) ) { questions.add( new XmlQuestionSetParser().parseMultipleChoiceQuestion( questionElement, new ParsingProblemRecorder() ) ); } else if ( name2.equalsIgnoreCase( "DragAndDropQuestion" ) ) { questions.add( new DragAndDropQuestion( questionElement ) ); } else { LOGGER.warning( "Unrecognised tag: " + name2 ); } } catch ( ParseException e ) { LOGGER.log( Level.WARNING, "Error parsing Question, skipping", e ); continue; } } } else { LOGGER.warning( "Unrecognised tag: " + tagName ); } } if ( questions.size() == 0 ) throw new ParseException( "No valid questions found in QuestionSet", 0 ); if ( name == null ) { LOGGER.warning( "no <Name> provided" ); name = "No name given"; } if ( recommendedTimePerQuestion == -1 ) { LOGGER.warning( "no <RecommendedTimePerQuestion> provided" ); recommendedTimePerQuestion = 120; // default two minutes per question } if ( category == "" ) { LOGGER.warning( "No category listed for this question set" ); } if ( description == null ) { LOGGER.warning( "no <Description> provided" ); description = "No description given"; } return new QuestionSet( name, description, recommendedTimePerQuestion, category, questions ); }
1071043_1
public Element asXML() { Element element = new Element("DragAndDropQuestion"); // Add attributes element.setAttribute("reuseFragments", Boolean.toString(reuseFragments)); // Create sub-tags ReadableElement questionTextElement = new ReadableElement("QuestionText"); questionTextElement.setText(questionText); ReadableElement explanationTextElement = new ReadableElement("ExplanationText"); explanationTextElement.setText(explanationText); Element fragmentListElement = new Element("ExtraFragments"); for (String fragment : extraFragments) { ReadableElement fragmentElement = new ReadableElement("Fragment"); fragmentElement.setText(fragment); fragmentListElement.addContent(fragmentElement); } // Add sub-tags element.addContent(questionTextElement); element.addContent(fragmentListElement); element.addContent(explanationTextElement); return element; }
1071043_2
public Element asXML() { ReadableElement element = new ReadableElement(XML_TAG_OPTION); element.setAttribute(XML_ATTRIBUTE_CORRECT, Boolean.toString(correct)); element.setText(optionText); return element; }
1071043_3
public int numberOfCorrectOptions() { int count = countCorrectOptions(options); return count; }
1071043_4
public String getSubstitutedExplanationText() { return substituteExplanationText(questionText, explanationText); }
1071767_0
public IPNMessage parse() { IPNMessage.Builder builder = new IPNMessage.Builder(nvp); if(validated) builder.validated(); for(Map.Entry<String, String> param : nvp.entrySet()) { addVariable(builder, param); } return builder.build(); }
1072630_0
@Override public QueryResult<Object> query(String statement, Map<String, Object> params) { try { Iterable<Object> result = gremlinExecutor.query(statement, params); return new QueryResultBuilder<Object>(result,resultConverter); } catch (Exception e) { throw new InvalidDataAccessResourceUsageException("Error executing statement " + statement, e); } }