Tabnine Logo
StringSource
Code IndexAdd Tabnine to your IDE (free)

How to use
StringSource
in
org.apache.stanbol.enhancer.servicesapi.impl

Best Java code snippets using org.apache.stanbol.enhancer.servicesapi.impl.StringSource (Showing top 9 results out of 315)

origin: stackoverflow.com

WebServiceTemplate template = new WebServiceTemplate(messageFactory);
Result result = new DOMResult();
template.sendSourceAndReceiveToResult(
  new StringSource("<content xmlns=\"http://tempuri.org\"/>"),
  new SoapActionCallback("http://tempuri.org/SOAPAction"),
  result);
origin: stackoverflow.com

 getWebServiceTemplate().marshalSendAndReceive("https://soap.endpoint",
  requestObj, new WebServiceMessageCallback() {

          public void doWithMessage(WebServiceMessage message) {
            try {
              SoapMessage soapMessage = (SoapMessage)message;
              SoapHeader header = soapMessage.getSoapHeader();
              StringSource headerSource = new StringSource("<Security><UsernameToken><SiteId>testlab1</SiteId>"+
"<Password>abcd1234</Password></UsernameToken></Security> ");
              Transformer transformer = TransformerFactory.newInstance().newTransformer();
              transformer.transform(headerSource, header.getResult());
            } catch (Exception e) {
              // exception handling
            }
          }
        });
origin: apache/stanbol

  /** @inheritDoc */
  public ImmutableGraph getGraph(EnhancementJobManager jobManager, 
             ContentItemFactory ciFactory) throws EnhancementException {
    if(graph == null) {
      ContentItem ci;
      try {
        ci = ciFactory.createContentItem(new StringSource(inputText));
      } catch (IOException e) {
        throw new IllegalStateException("Unable to create a ContentItem" +
            "using '"+ciFactory.getClass().getSimpleName()+"'!",e);
      }
      if(chain == null){
        jobManager.enhanceContent(ci);
      } else { //parsing null as chain does not work!
        jobManager.enhanceContent(ci,chain);
      }
      graph = ci.getMetadata().getImmutableGraph();
    }
    return graph;
  }
}
origin: apache/stanbol

    .build());
ContentItem ci = ciFactory.createContentItem(new StringSource(content));
if(!buildAjaxview){ //rewrite to a normal EnhancementRequest
  return enhanceFromData(ci, false, null, false, null, false, null, headers);
origin: org.apache.stanbol/org.apache.stanbol.enhancer.jersey

    .build());
ContentItem ci = ciFactory.createContentItem(new StringSource(content));
if(!buildAjaxview){ //rewrite to a normal EnhancementRequest
  return enhanceFromData(ci, false, null, false, null, false, null, headers);
origin: org.apache.stanbol/org.apache.stanbol.enhancer.test

/**
 * Tests correct handling of  UTF-8 as default charset
 * @throws IOException
 */
@Test
public void testString() throws IOException{
  String test = "Exámplê";
  //first via a StringSource
  ContentSource cs = new StringSource(test);
  Blob blob = createBlob(cs);
  Assert.assertEquals("text/plain", blob.getMimeType());
  Assert.assertTrue(blob.getParameter().containsKey("charset"));
  Assert.assertEquals(UTF8.name(), blob.getParameter().get("charset"));
  String value = new String(IOUtils.toByteArray(blob.getStream()),UTF8);
  Assert.assertEquals(test, value);
}
/**
origin: apache/stanbol

/**
 * Tests correct handling of  UTF-8 as default charset
 * @throws IOException
 */
@Test
public void testString() throws IOException{
  String test = "Exámplê";
  //first via a StringSource
  ContentSource cs = new StringSource(test);
  Blob blob = createBlob(cs);
  Assert.assertEquals("text/plain", blob.getMimeType());
  Assert.assertTrue(blob.getParameter().containsKey("charset"));
  Assert.assertEquals(UTF8.name(), blob.getParameter().get("charset"));
  String value = new String(IOUtils.toByteArray(blob.getStream()),UTF8);
  Assert.assertEquals(test, value);
}
/**
origin: apache/stanbol

/**
 * This tests that texts with custom charsets are converted to UTF-8. 
 * @throws IOException
 */
@Test
public void testStringWithCustomCharset() throws IOException{
  String test = "Exámplê";
  Charset ISO8859_4 = Charset.forName("ISO-8859-4");
  //first via a StringSource
  ContentSource cs = new StringSource(test,ISO8859_4,"text/plain");
  Blob blob = createBlob(cs);
  Assert.assertEquals("text/plain", blob.getMimeType());
  Assert.assertTrue(blob.getParameter().containsKey("charset"));
  Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
  //2nd via a ByteArray
  byte[] data = test.getBytes(ISO8859_4);
  cs = new ByteArraySource(data,"text/plain; charset="+ISO8859_4.name());
  blob = createBlob(cs);
  Assert.assertEquals("text/plain", blob.getMimeType());
  Assert.assertTrue(blob.getParameter().containsKey("charset"));
  Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
  //3rd as Stream
  cs = new StreamSource(new ByteArrayInputStream(data), "text/plain; charset="+ISO8859_4.name());
  blob = createBlob(cs);
  Assert.assertEquals("text/plain", blob.getMimeType());
  Assert.assertTrue(blob.getParameter().containsKey("charset"));
  Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
  cs = new StreamSource(new ByteArrayInputStream(data), "text/plain; "+ISO8859_4.name());
}
/**
origin: org.apache.stanbol/org.apache.stanbol.enhancer.test

/**
 * This tests that texts with custom charsets are converted to UTF-8. 
 * @throws IOException
 */
@Test
public void testStringWithCustomCharset() throws IOException{
  String test = "Exámplê";
  Charset ISO8859_4 = Charset.forName("ISO-8859-4");
  //first via a StringSource
  ContentSource cs = new StringSource(test,ISO8859_4,"text/plain");
  Blob blob = createBlob(cs);
  Assert.assertEquals("text/plain", blob.getMimeType());
  Assert.assertTrue(blob.getParameter().containsKey("charset"));
  Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
  //2nd via a ByteArray
  byte[] data = test.getBytes(ISO8859_4);
  cs = new ByteArraySource(data,"text/plain; charset="+ISO8859_4.name());
  blob = createBlob(cs);
  Assert.assertEquals("text/plain", blob.getMimeType());
  Assert.assertTrue(blob.getParameter().containsKey("charset"));
  Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
  //3rd as Stream
  cs = new StreamSource(new ByteArrayInputStream(data), "text/plain; charset="+ISO8859_4.name());
  blob = createBlob(cs);
  Assert.assertEquals("text/plain", blob.getMimeType());
  Assert.assertTrue(blob.getParameter().containsKey("charset"));
  Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
  cs = new StreamSource(new ByteArrayInputStream(data), "text/plain; "+ISO8859_4.name());
}
/**
org.apache.stanbol.enhancer.servicesapi.implStringSource

Javadoc

Allows to use a String as a Source for Content.

Most used methods

  • <init>
    Allows to creates a StringSource with an other media type that text/plain and an custom Charset used

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • addToBackStack (FragmentTransaction)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now