code
stringlengths
73
34.1k
label
stringclasses
1 value
private static void loadFile(String filePath) { final Path path = FileSystems.getDefault().getPath(filePath); try { data.clear(); data.load(Files.newBufferedReader(path)); } catch(IOException e) { LOG.warn("Exception while loading " + path.toString(), e); ...
java
public void setValue(String constantValue) { this.fieldSource = SOURCE_VALUE; this.fieldRefName = null; this.returnedByProcedure = false; this.constantValue = constantValue; }
java
public final int getJdbcType() { switch (this.fieldSource) { case SOURCE_FIELD : return this.getFieldRef().getJdbcType().getType(); case SOURCE_NULL : return java.sql.Types.NULL; case SOURCE_VALUE : return j...
java
private boolean isCacheable(PipelineContext context) throws GeomajasException { VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class); return !(layer instanceof VectorLayerLazyFeatureConversionSupport && ((VectorLayerLazyFeatureConversionSupport) layer).useLazyFeatureConversion()); }
java
@Deprecated public List<Double> getResolutions() { List<Double> resolutions = new ArrayList<Double>(); for (ScaleInfo scale : getZoomLevels()) { resolutions.add(1. / scale.getPixelPerUnit()); } return resolutions; }
java
@Deprecated public void setResolutions(List<Double> resolutions) { getZoomLevels().clear(); for (Double resolution : resolutions) { getZoomLevels().add(new ScaleInfo(1. / resolution)); } }
java
public static void registerTinyTypes(Class<?> head, Class<?>... tail) { final Set<HeaderDelegateProvider> systemRegisteredHeaderProviders = stealAcquireRefToHeaderDelegateProviders(); register(head, systemRegisteredHeaderProviders); for (Class<?> tt : tail) { register(tt, systemRegis...
java
public static String generateQuery(final Map<String,Object> params){ final StringBuilder sb = new StringBuilder(); boolean newEntry = false; sb.append("{"); for(final Entry<String,Object> param: params.entrySet()){ if(newEntry){ sb.append(", "); } sb.append(param.getKey()); sb.append(": "); ...
java
public static String generateQuery(final String key, final Object value) { final Map<String, Object> params = new HashMap<>(); params.put(key, value); return generateQuery(params); }
java
private static Object getParam(final Object param) { final StringBuilder sb = new StringBuilder(); if(param instanceof String){ sb.append("'"); sb.append((String)param); sb.append("'"); } else if(param instanceof Boolean){ sb.append(String.valueOf((Boolean)param)); } else if(param insta...
java
public static String getOjbClassName(ResultSet rs) { try { return rs.getString(OJB_CLASS_COLUMN); } catch (SQLException e) { return null; } }
java
public void setOjbQuery(org.apache.ojb.broker.query.Query ojbQuery) { this.ojbQuery = ojbQuery; }
java
@GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) public Response getCorporateGroupIdPrefix(@PathParam("name") final String organizationId){ LOG.info("Got a get corporate groupId prefix request for organization " + organizationId +"...
java
@POST @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) public Response addCorporateGroupIdPrefix(@Auth final DbCredential credential, @PathParam("name") final String organizationId, final String corporateGroupId){ LOG.info("Got an add a corporate groupId prefix request for organization " + organizati...
java
@DELETE @Path("/{name}" + ServerAPI.GET_CORPORATE_GROUPIDS) public Response removeCorporateGroupIdPrefix(@Auth final DbCredential credential, @PathParam("name") final String organizationId, final String corporateGroupId){ LOG.info("Got an remove a corporate groupId prefix request for organization " + or...
java
private StyleFilter findStyleFilter(Object feature, List<StyleFilter> styles) { for (StyleFilter styleFilter : styles) { if (styleFilter.getFilter().evaluate(feature)) { return styleFilter; } } return new StyleFilterImpl(); }
java
final void roll(final long timeForSuffix) { final File backupFile = this.prepareBackupFile(timeForSuffix); // close filename this.getAppender().closeFile(); // rename filename on disk to filename+suffix(+number) this.doFileRoll(this.getAppender().getIoFile(), backupFile); // setup new file '...
java
private void doFileRoll(final File from, final File to) { final FileHelper fileHelper = FileHelper.getInstance(); if (!fileHelper.deleteExisting(to)) { this.getAppender().getErrorHandler() .error("Unable to delete existing " + to + " for rename"); } final String original = from.toString(...
java
public static spilloverpolicy_lbvserver_binding[] get(nitro_service service, String name) throws Exception{ spilloverpolicy_lbvserver_binding obj = new spilloverpolicy_lbvserver_binding(); obj.set_name(name); spilloverpolicy_lbvserver_binding response[] = (spilloverpolicy_lbvserver_binding[]) obj.get_resources(se...
java
public static appfwprofile_excluderescontenttype_binding[] get(nitro_service service, String name) throws Exception{ appfwprofile_excluderescontenttype_binding obj = new appfwprofile_excluderescontenttype_binding(); obj.set_name(name); appfwprofile_excluderescontenttype_binding response[] = (appfwprofile_excluder...
java
public static base_response update(nitro_service client, sslparameter resource) throws Exception { sslparameter updateresource = new sslparameter(); updateresource.quantumsize = resource.quantumsize; updateresource.crlmemorysizemb = resource.crlmemorysizemb; updateresource.strictcachecks = resource.strictcachec...
java
public static base_response unset(nitro_service client, sslparameter resource, String[] args) throws Exception{ sslparameter unsetresource = new sslparameter(); return unsetresource.unset_resource(client,args); }
java
public static sslparameter get(nitro_service service) throws Exception{ sslparameter obj = new sslparameter(); sslparameter[] response = (sslparameter[])obj.get_resources(service); return response[0]; }
java
public static base_response add(nitro_service client, spilloverpolicy resource) throws Exception { spilloverpolicy addresource = new spilloverpolicy(); addresource.name = resource.name; addresource.rule = resource.rule; addresource.action = resource.action; addresource.comment = resource.comment; return add...
java
public static base_response update(nitro_service client, spilloverpolicy resource) throws Exception { spilloverpolicy updateresource = new spilloverpolicy(); updateresource.name = resource.name; updateresource.rule = resource.rule; updateresource.action = resource.action; updateresource.comment = resource.com...
java
public static spilloverpolicy[] get(nitro_service service, options option) throws Exception{ spilloverpolicy obj = new spilloverpolicy(); spilloverpolicy[] response = (spilloverpolicy[])obj.get_resources(service,option); return response; }
java
public static spilloverpolicy get(nitro_service service, String name) throws Exception{ spilloverpolicy obj = new spilloverpolicy(); obj.set_name(name); spilloverpolicy response = (spilloverpolicy) obj.get_resource(service); return response; }
java
public static <IN> PaddedList<IN> valueOf(List<IN> list, IN padding) { return new PaddedList<IN>(list, padding); }
java
public static base_response add(nitro_service client, locationfile resource) throws Exception { locationfile addresource = new locationfile(); addresource.Locationfile = resource.Locationfile; addresource.format = resource.format; return addresource.add_resource(client); }
java
public static base_response delete(nitro_service client) throws Exception { locationfile deleteresource = new locationfile(); return deleteresource.delete_resource(client); }
java
public static locationfile get(nitro_service service) throws Exception{ locationfile obj = new locationfile(); locationfile[] response = (locationfile[])obj.get_resources(service); return response[0]; }
java
public static sslcertkey_sslocspresponder_binding[] get(nitro_service service, String certkey) throws Exception{ sslcertkey_sslocspresponder_binding obj = new sslcertkey_sslocspresponder_binding(); obj.set_certkey(certkey); sslcertkey_sslocspresponder_binding response[] = (sslcertkey_sslocspresponder_binding[]) o...
java
public static appflowpolicy_appflowpolicylabel_binding[] get(nitro_service service, String name) throws Exception{ appflowpolicy_appflowpolicylabel_binding obj = new appflowpolicy_appflowpolicylabel_binding(); obj.set_name(name); appflowpolicy_appflowpolicylabel_binding response[] = (appflowpolicy_appflowpolicyla...
java
public static authenticationvserver_authenticationnegotiatepolicy_binding[] get(nitro_service service, String name) throws Exception{ authenticationvserver_authenticationnegotiatepolicy_binding obj = new authenticationvserver_authenticationnegotiatepolicy_binding(); obj.set_name(name); authenticationvserver_authe...
java
public static base_response update(nitro_service client, rnatparam resource) throws Exception { rnatparam updateresource = new rnatparam(); updateresource.tcpproxy = resource.tcpproxy; return updateresource.update_resource(client); }
java
public static base_response unset(nitro_service client, rnatparam resource, String[] args) throws Exception{ rnatparam unsetresource = new rnatparam(); return unsetresource.unset_resource(client,args); }
java
public static rnatparam get(nitro_service service) throws Exception{ rnatparam obj = new rnatparam(); rnatparam[] response = (rnatparam[])obj.get_resources(service); return response[0]; }
java
public static base_response update(nitro_service client, nd6ravariables resource) throws Exception { nd6ravariables updateresource = new nd6ravariables(); updateresource.vlan = resource.vlan; updateresource.ceaserouteradv = resource.ceaserouteradv; updateresource.sendrouteradv = resource.sendrouteradv; update...
java
public static base_responses update(nitro_service client, nd6ravariables resources[]) throws Exception { base_responses result = null; if (resources != null && resources.length > 0) { nd6ravariables updateresources[] = new nd6ravariables[resources.length]; for (int i=0;i<resources.length;i++){ updateresou...
java
public static nd6ravariables[] get(nitro_service service, options option) throws Exception{ nd6ravariables obj = new nd6ravariables(); nd6ravariables[] response = (nd6ravariables[])obj.get_resources(service,option); return response; }
java
public static nd6ravariables get(nitro_service service, Long vlan) throws Exception{ nd6ravariables obj = new nd6ravariables(); obj.set_vlan(vlan); nd6ravariables response = (nd6ravariables) obj.get_resource(service); return response; }
java
public static nd6ravariables[] get(nitro_service service, Long vlan[]) throws Exception{ if (vlan !=null && vlan.length>0) { nd6ravariables response[] = new nd6ravariables[vlan.length]; nd6ravariables obj[] = new nd6ravariables[vlan.length]; for (int i=0;i<vlan.length;i++) { obj[i] = new nd6ravariables()...
java
public static gslbrunningconfig get(nitro_service service) throws Exception{ gslbrunningconfig obj = new gslbrunningconfig(); gslbrunningconfig[] response = (gslbrunningconfig[])obj.get_resources(service); return response[0]; }
java
public static base_response update(nitro_service client, callhome resource) throws Exception { callhome updateresource = new callhome(); updateresource.emailaddress = resource.emailaddress; updateresource.proxymode = resource.proxymode; updateresource.ipaddress = resource.ipaddress; updateresource.port = reso...
java
public static base_response unset(nitro_service client, callhome resource, String[] args) throws Exception{ callhome unsetresource = new callhome(); return unsetresource.unset_resource(client,args); }
java
public static callhome get(nitro_service service) throws Exception{ callhome obj = new callhome(); callhome[] response = (callhome[])obj.get_resources(service); return response[0]; }
java
public static csvserver_appflowpolicy_binding[] get(nitro_service service, String name) throws Exception{ csvserver_appflowpolicy_binding obj = new csvserver_appflowpolicy_binding(); obj.set_name(name); csvserver_appflowpolicy_binding response[] = (csvserver_appflowpolicy_binding[]) obj.get_resources(service); ...
java
public static cachepolicy_cacheglobal_binding[] get(nitro_service service, String policyname) throws Exception{ cachepolicy_cacheglobal_binding obj = new cachepolicy_cacheglobal_binding(); obj.set_policyname(policyname); cachepolicy_cacheglobal_binding response[] = (cachepolicy_cacheglobal_binding[]) obj.get_reso...
java
public static sslglobal_sslpolicy_binding[] get(nitro_service service) throws Exception{ sslglobal_sslpolicy_binding obj = new sslglobal_sslpolicy_binding(); sslglobal_sslpolicy_binding response[] = (sslglobal_sslpolicy_binding[]) obj.get_resources(service); return response; }
java
public static sslglobal_sslpolicy_binding[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception{ sslglobal_sslpolicy_binding obj = new sslglobal_sslpolicy_binding(); options option = new options(); option.set_filter(filter); sslglobal_sslpolicy_binding[] response = (sslglobal_sslpolicy_bi...
java
public Collection<V> put(K key, Collection<V> collection) { return map.put(key, collection); }
java
public void add(K key, V value) { if (treatCollectionsAsImmutable) { Collection<V> newC = cf.newCollection(); Collection<V> c = map.get(key); if (c != null) { newC.addAll(c); } newC.add(value); map.put(key, newC); // replacing the old collection } else { ...
java
public void removeMapping(K key, V value) { if (treatCollectionsAsImmutable) { Collection<V> c = map.get(key); if (c != null) { Collection<V> newC = cf.newCollection(); newC.addAll(c); newC.remove(value); map.put(key, newC); } } else { Collecti...
java
public CollectionValuedMap<K, V> deltaClone() { CollectionValuedMap<K, V> result = new CollectionValuedMap<K, V>(null, cf, true); result.map = new DeltaMap<K, Collection<V>>(this.map); return result; }
java
public static linkset_interface_binding[] get(nitro_service service, String id) throws Exception{ linkset_interface_binding obj = new linkset_interface_binding(); obj.set_id(id); linkset_interface_binding response[] = (linkset_interface_binding[]) obj.get_resources(service); return response; }
java
public static long count(nitro_service service, String id) throws Exception{ linkset_interface_binding obj = new linkset_interface_binding(); obj.set_id(id); options option = new options(); option.set_count(true); linkset_interface_binding response[] = (linkset_interface_binding[]) obj.get_resources(service,o...
java
public static tmtrafficpolicy_lbvserver_binding[] get(nitro_service service, String name) throws Exception{ tmtrafficpolicy_lbvserver_binding obj = new tmtrafficpolicy_lbvserver_binding(); obj.set_name(name); tmtrafficpolicy_lbvserver_binding response[] = (tmtrafficpolicy_lbvserver_binding[]) obj.get_resources(se...
java
public static vlan_interface_binding[] get(nitro_service service, Long id) throws Exception{ vlan_interface_binding obj = new vlan_interface_binding(); obj.set_id(id); vlan_interface_binding response[] = (vlan_interface_binding[]) obj.get_resources(service); return response; }
java
public static rewritepolicy_csvserver_binding[] get(nitro_service service, String name) throws Exception{ rewritepolicy_csvserver_binding obj = new rewritepolicy_csvserver_binding(); obj.set_name(name); rewritepolicy_csvserver_binding response[] = (rewritepolicy_csvserver_binding[]) obj.get_resources(service); ...
java
public static tunneltrafficpolicy[] get(nitro_service service, options option) throws Exception{ tunneltrafficpolicy obj = new tunneltrafficpolicy(); tunneltrafficpolicy[] response = (tunneltrafficpolicy[])obj.get_resources(service,option); return response; }
java
public static tunneltrafficpolicy get(nitro_service service, String name) throws Exception{ tunneltrafficpolicy obj = new tunneltrafficpolicy(); obj.set_name(name); tunneltrafficpolicy response = (tunneltrafficpolicy) obj.get_resource(service); return response; }
java
public static vpnglobal_intranetip_binding[] get(nitro_service service) throws Exception{ vpnglobal_intranetip_binding obj = new vpnglobal_intranetip_binding(); vpnglobal_intranetip_binding response[] = (vpnglobal_intranetip_binding[]) obj.get_resources(service); return response; }
java
public static base_response add(nitro_service client, sslaction resource) throws Exception { sslaction addresource = new sslaction(); addresource.name = resource.name; addresource.clientauth = resource.clientauth; addresource.clientcert = resource.clientcert; addresource.certheader = resource.certheader; ad...
java
public static base_responses add(nitro_service client, sslaction resources[]) throws Exception { base_responses result = null; if (resources != null && resources.length > 0) { sslaction addresources[] = new sslaction[resources.length]; for (int i=0;i<resources.length;i++){ addresources[i] = new sslaction(...
java
public static sslaction[] get(nitro_service service) throws Exception{ sslaction obj = new sslaction(); sslaction[] response = (sslaction[])obj.get_resources(service); return response; }
java
public static sslaction get(nitro_service service, String name) throws Exception{ sslaction obj = new sslaction(); obj.set_name(name); sslaction response = (sslaction) obj.get_resource(service); return response; }
java
public static rewriteglobal_binding get(nitro_service service) throws Exception{ rewriteglobal_binding obj = new rewriteglobal_binding(); rewriteglobal_binding response = (rewriteglobal_binding) obj.get_resource(service); return response; }
java
public static vpath_stats get(nitro_service service) throws Exception{ vpath_stats obj = new vpath_stats(); vpath_stats[] response = (vpath_stats[])obj.stat_resources(service); return response[0]; }
java
public static aaauser_auditsyslogpolicy_binding[] get(nitro_service service, String username) throws Exception{ aaauser_auditsyslogpolicy_binding obj = new aaauser_auditsyslogpolicy_binding(); obj.set_username(username); aaauser_auditsyslogpolicy_binding response[] = (aaauser_auditsyslogpolicy_binding[]) obj.get_...
java
public static lbvserver_cachepolicy_binding[] get(nitro_service service, String name) throws Exception{ lbvserver_cachepolicy_binding obj = new lbvserver_cachepolicy_binding(); obj.set_name(name); lbvserver_cachepolicy_binding response[] = (lbvserver_cachepolicy_binding[]) obj.get_resources(service); return res...
java
public static tunnelip_stats[] get(nitro_service service) throws Exception{ tunnelip_stats obj = new tunnelip_stats(); tunnelip_stats[] response = (tunnelip_stats[])obj.stat_resources(service); return response; }
java
public static tunnelip_stats get(nitro_service service, String tunnelip) throws Exception{ tunnelip_stats obj = new tunnelip_stats(); obj.set_tunnelip(tunnelip); tunnelip_stats response = (tunnelip_stats) obj.stat_resource(service); return response; }
java
public void updateSequenceElement(int[] sequence, int pos, int oldVal) { if(models != null){ for(int i = 0; i < models.length; i++) models[i].updateSequenceElement(sequence, pos, oldVal); return; } model1.updateSequenceElement(sequence, pos, 0); model2.updateSequenceElement(s...
java
public void setInitialSequence(int[] sequence) { if(models != null){ for(int i = 0; i < models.length; i++) models[i].setInitialSequence(sequence); return; } model1.setInitialSequence(sequence); model2.setInitialSequence(sequence); }
java
public static <T> IteratorFromReaderFactory<T> getFactory(String delim, Function<String,T> op) { return new DelimitRegExIteratorFactory<T>(delim, op); }
java
public static lbmonbindings_servicegroup_binding[] get(nitro_service service, String monitorname) throws Exception{ lbmonbindings_servicegroup_binding obj = new lbmonbindings_servicegroup_binding(); obj.set_monitorname(monitorname); lbmonbindings_servicegroup_binding response[] = (lbmonbindings_servicegroup_bindi...
java
public final List<MtasSolrStatus> checkForExceptions() { List<MtasSolrStatus> statusWithException = null; for (MtasSolrStatus item : data) { if (item.checkResponseForException()) { if (statusWithException == null) { statusWithException = new ArrayList<>(); } statusWithExc...
java
public static authenticationradiuspolicy_authenticationvserver_binding[] get(nitro_service service, String name) throws Exception{ authenticationradiuspolicy_authenticationvserver_binding obj = new authenticationradiuspolicy_authenticationvserver_binding(); obj.set_name(name); authenticationradiuspolicy_authentic...
java
public static vpnvserver_authenticationsamlpolicy_binding[] get(nitro_service service, String name) throws Exception{ vpnvserver_authenticationsamlpolicy_binding obj = new vpnvserver_authenticationsamlpolicy_binding(); obj.set_name(name); vpnvserver_authenticationsamlpolicy_binding response[] = (vpnvserver_authen...
java
public static base_response convert(nitro_service client, sslpkcs8 resource) throws Exception { sslpkcs8 convertresource = new sslpkcs8(); convertresource.pkcs8file = resource.pkcs8file; convertresource.keyfile = resource.keyfile; convertresource.keyform = resource.keyform; convertresource.password = resource...
java
public static ci[] get(nitro_service service) throws Exception{ ci obj = new ci(); ci[] response = (ci[])obj.get_resources(service); return response; }
java
public static base_response add(nitro_service client, sslcipher resource) throws Exception { sslcipher addresource = new sslcipher(); addresource.ciphergroupname = resource.ciphergroupname; addresource.ciphgrpalias = resource.ciphgrpalias; return addresource.add_resource(client); }
java
public static base_responses add(nitro_service client, sslcipher resources[]) throws Exception { base_responses result = null; if (resources != null && resources.length > 0) { sslcipher addresources[] = new sslcipher[resources.length]; for (int i=0;i<resources.length;i++){ addresources[i] = new sslcipher(...
java
public static base_response delete(nitro_service client, String ciphergroupname) throws Exception { sslcipher deleteresource = new sslcipher(); deleteresource.ciphergroupname = ciphergroupname; return deleteresource.delete_resource(client); }
java
public static base_responses delete(nitro_service client, String ciphergroupname[]) throws Exception { base_responses result = null; if (ciphergroupname != null && ciphergroupname.length > 0) { sslcipher deleteresources[] = new sslcipher[ciphergroupname.length]; for (int i=0;i<ciphergroupname.length;i++){ ...
java
public static sslcipher[] get(nitro_service service) throws Exception{ sslcipher obj = new sslcipher(); sslcipher[] response = (sslcipher[])obj.get_resources(service); return response; }
java
public static sslcipher get(nitro_service service, String ciphergroupname) throws Exception{ sslcipher obj = new sslcipher(); obj.set_ciphergroupname(ciphergroupname); sslcipher response = (sslcipher) obj.get_resource(service); return response; }
java
public static sslcipher[] get(nitro_service service, String ciphergroupname[]) throws Exception{ if (ciphergroupname !=null && ciphergroupname.length>0) { sslcipher response[] = new sslcipher[ciphergroupname.length]; sslcipher obj[] = new sslcipher[ciphergroupname.length]; for (int i=0;i<ciphergroupname.leng...
java
public static base_response add(nitro_service client, transformpolicy resource) throws Exception { transformpolicy addresource = new transformpolicy(); addresource.name = resource.name; addresource.rule = resource.rule; addresource.profilename = resource.profilename; addresource.comment = resource.comment; ...
java
public static base_response update(nitro_service client, transformpolicy resource) throws Exception { transformpolicy updateresource = new transformpolicy(); updateresource.name = resource.name; updateresource.rule = resource.rule; updateresource.profilename = resource.profilename; updateresource.comment = re...
java
public static transformpolicy[] get(nitro_service service) throws Exception{ transformpolicy obj = new transformpolicy(); transformpolicy[] response = (transformpolicy[])obj.get_resources(service); return response; }
java
public static transformpolicy get(nitro_service service, String name) throws Exception{ transformpolicy obj = new transformpolicy(); obj.set_name(name); transformpolicy response = (transformpolicy) obj.get_resource(service); return response; }
java
public int compareTo(WordTag wordTag) { int first = (word != null ? word().compareTo(wordTag.word()) : 0); if(first != 0) return first; else { if (tag() == null) { if (wordTag.tag() == null) return 0; else return -1; } return tag().c...
java
protected void rehash(int newCapacity) { int oldCapacity = table.length; //if (oldCapacity == newCapacity) return; long oldTable[] = table; int oldValues[] = values; byte oldState[] = state; long newTable[] = new long[newCapacity]; int newValues[] = new int[newCapacity]; byte newState[] = new byte[...
java
public boolean removeKey(long key) { int i = indexOfKey(key); if (i<0) return false; // key not contained this.state[i]=REMOVED; this.values[i]=0; // delta this.distinct--; if (this.distinct < this.lowWaterMark) { int newCapacity = chooseShrinkCapacity(this.distinct,this.minLoadFactor, this.maxLoadFa...
java
public static DocumentBuilder getXmlParser() { DocumentBuilder db = null; try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); //Disable DTD loading and validation //See http://stackoverflow.com/questions/155101/make-documentbuilder-p...
java
public static String readUntilTag(Reader r) throws IOException { if (!r.ready()) { return ""; } StringBuilder b = new StringBuilder(); int c = r.read(); while (c >= 0 && c != '<') { b.append((char) c); c = r.read(); } return b.toString(); }
java
public static int findSpace(String haystack, int begin) { int space = haystack.indexOf(' ', begin); int nbsp = haystack.indexOf('\u00A0', begin); if (space == -1 && nbsp == -1) { return -1; } else if (space >= 0 && nbsp >= 0) { return Math.min(space, nbsp); } else { // eg o...
java
public static String readTag(Reader r) throws IOException { if ( ! r.ready()) { return null; } StringBuilder b = new StringBuilder("<"); int c = r.read(); while (c >= 0) { b.append((char) c); if (c == '>') { break; } c = r.read(); } if (b.le...
java
public static Document readDocumentFromString(String s) throws Exception { InputSource in = new InputSource(new StringReader(s)); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(false); return factory.newDocumentBuilder().parse(in); }
java