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.ma...
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.ma...
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()) ...
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 BasicNameValuePa...
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 BasicNameValuePa...
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...
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...
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...
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 { ...
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); ...
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.directi...
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()) - ...
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() + (thi...
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() + (thi...
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 + ...
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 n...
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 n...
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 n...
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 n...
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 n...
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 n...
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 n...
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 = s...
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...
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 consumerSer...
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...
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 w...
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 start...
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 (StreamNotFoundExcept...
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 (Exceptio...
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) ...
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) ...
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)...
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 indicati...
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 indicati...
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 indicati...
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 indicati...
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 indicati...
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 indicati...
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 indicati...
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 ...
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 ...
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 ...
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.setDefault...
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.setDefault...
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[] { ...
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....
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 = ...
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(que...
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 InvalidDataAccessResourceU...