當前位置: 首頁>>代碼示例>>Java>>正文


Java Header.getValue方法代碼示例

本文整理匯總了Java中javax.mail.Header.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Header.getValue方法的具體用法?Java Header.getValue怎麽用?Java Header.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.mail.Header的用法示例。


在下文中一共展示了Header.getValue方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getHeaders

import javax.mail.Header; //導入方法依賴的package包/類
protected MessageHeaders getHeaders(MimeMessage message) throws MessagingException {

        Map<String, String> headerMap = new HashMap<>();

        // oh wow 2015 and it's untyped and uses Enumeration
        Enumeration allHeaders = message.getAllHeaders();
        while (allHeaders.hasMoreElements()) {
            Header header = (Header) allHeaders.nextElement();
            String headerName = header.getName();
            String headerVal = header.getValue();

            headerMap.put(headerName, headerVal);

        }

        return new MessageHeaders(headerMap);
    }
 
開發者ID:SpartaSystems,項目名稱:holdmail,代碼行數:18,代碼來源:SMTPHandler.java

示例2: createLog

import javax.mail.Header; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private static String createLog(final Message msg) {
    StringBuilder bldr = new StringBuilder();
    Enumeration<Header> allHeaders;
    try {
        allHeaders = msg.getAllHeaders();
    } catch (MessagingException e) {
        return null;
    }
    while (allHeaders.hasMoreElements()) {
        Header header = allHeaders.nextElement();
        String name = header.getName();
        String value = header.getValue();
        bldr.append(name);
        bldr.append(":");
        bldr.append(value);
        bldr.append("\n");
    }
    return StringUtils.truncate(bldr.toString(), LOG_FIELD_WIDTH);
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:21,代碼來源:MailAckProcessor.java

示例3: extractHeadersFromMail

import javax.mail.Header; //導入方法依賴的package包/類
protected Map<String, Object> extractHeadersFromMail(Message mailMessage, Exchange exchange) throws MessagingException {
    Map<String, Object> answer = new HashMap<String, Object>();
    Enumeration<?> names = mailMessage.getAllHeaders();

    while (names.hasMoreElements()) {
        Header header = (Header) names.nextElement();
        String value = header.getValue();
        if (headerFilterStrategy != null && !headerFilterStrategy.applyFilterToExternalHeaders(header.getName(), value, exchange)) {
            CollectionHelper.appendValue(answer, header.getName(), value);
        }
    }

    return answer;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:15,代碼來源:MailBinding.java

示例4: createAddress

import javax.mail.Header; //導入方法依賴的package包/類
@Nonnull
private static InternetAddress createAddress(final Header header, final String typeOfAddress) {
	try {
		return new InternetAddress(header.getValue());
	} catch (final AddressException e) {
		throw new MimeMessageParseException(format(MimeMessageParseException.ERROR_PARSING_ADDRESS, typeOfAddress), e);
	}
}
 
開發者ID:bbottema,項目名稱:simple-java-mail,代碼行數:9,代碼來源:MimeMessageParser.java

示例5: main

import javax.mail.Header; //導入方法依賴的package包/類
public static void main(String[] args) throws SUTimeParsingError, MessagingException {
HashMap<String,String>  hm=new HashMap<String,String>();
hm.put("kk","ghhj");
for(java.util.Map.Entry<String, String> e: hm.entrySet()){
	//System.out.println("Key " + e.getKey());
	//System.out.println("Value " + e.getValue());

}

   String s="NextPart_000_005D_01CC73D5.3BA43FB0\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"\nContent-Transfer-Encoding: quoted-printable\n\nStuff:\n\n            Please read this stuff at the beginning of each week.  =\nFeel free to discuss it throughout the week.\n\n\n--=20\n\nMrs. Suzy M. Smith\n555-555-5555\[email protected]\n------=_NextPart_000_005D_01CC73D5.3BA43FB0\nContent-Type: text/html;\n\tcharset=\"iso-8859-1\"\nContent-Transfer-Encoding: quoted-printable\n\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<HTML><HEAD>\n<META content=3D\"text/html; charset=3Diso-8859-1\" =\nhttp-equiv=3DContent-Type>\n<META name=3DGENERATOR content=3D\"MSHTML 9.00.8112.16434\">\n<STYLE></STYLE>\n</HEAD>\n<BODY bgColor=3D#ffffff>\n<DIV>\n<P style=3D\"MARGIN: 0in 0in 0pt\" class=3DMsoNormal><SPAN=20\nstyle=3D\"mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New =\nRoman'; mso-bidi-font-family: 'Times New =\nRoman'\">Stuff:<?xml:namespace=20\nprefix =3D o ns =3D \"urn:schemas-microsoft-com:office:office\"=20\n/><o:p></o:p></SPAN></P>\n<P style=3D\"MARGIN: 0in 0in 0pt\" class=3DMsoNormal><SPAN=20\nstyle=3D\"mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New =\nRoman'; mso-bidi-font-family: 'Times New Roman'\"><SPAN=20\nstyle=3D\"mso-tab-count: =\n1\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20\n</SPAN></SPAN>Please read this stuff at the beginning of each =\nweek.&nbsp; Feel=20\nfree to discuss it throughout the week.<SPAN=20\nstyle=3D\"mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New =\nRoman'; mso-bidi-font-family: 'Times New =\nRoman'\"><o:p></o:p></SPAN></P></DIV>\n<DIV><BR>-- <BR><BR>Mrs. Suzy M. Smith<BR>555-555-5555<BR><A=20\nhref=3D\"mailto:[email protected]\">[email protected]</A></DIV></BODY=\n></HTML>\n\n------=_NextPart_000_005D_01CC73D5.3BA43FB0--\n\n";
   InputStream stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
   Session ss = Session.getDefaultInstance(new Properties());
   MimeMessage mi=new MimeMessage(ss,stream);
   mi.getAllHeaderLines();
   for (Enumeration<Header> e = mi.getAllHeaders(); e.hasMoreElements();) {
       Header h = e.nextElement();
       String name=h.getName();
       String value=h.getValue();
       System.out.println(value);
       h.getValue();
   }
   //System.out.println("String: " + s);
     //parse(s);
     System.out.println();

 }
 
開發者ID:vibhor1319,項目名稱:activent,代碼行數:27,代碼來源:SUTimeSimpleParser.java

示例6: run_me

import javax.mail.Header; //導入方法依賴的package包/類
@SuppressLint("NewApi") public static void run_me(ArrayList<String> args) throws MessagingException {
//HashMap<String,String>  hm=new HashMap<String,String>();
//hm.put("kk","ghhj");
/*for(java.util.Map.Entry<String, String> e: hm.entrySet()){
	//System.out.println("Key " + e.getKey());
	//System.out.println("Value " + e.getValue());
	
}
*/
  for(String s:args)
  {
 //  String s="";
   InputStream stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
   Session ss = Session.getDefaultInstance(new Properties());
   MimeMessage mi=new MimeMessage(ss,stream); 
   mi.getAllHeaderLines();
   for (Enumeration<Header> e = mi.getAllHeaders(); e.hasMoreElements();) {
       Header h = e.nextElement();
       String name=h.getName();
       String value=h.getValue();
       System.out.println(value);
       System.out.println(name);
       h.getValue();
   }
   System.out.println("String: " + s);
    // parse(s);
     System.out.println();
  }
 }
 
開發者ID:vibhor1319,項目名稱:activent,代碼行數:30,代碼來源:TimeTagger.java

示例7: bodyPartRequest

import javax.mail.Header; //導入方法依賴的package包/類
private Response bodyPartRequest(final MimeBodyPart body, final Map<String, String> references) throws Exception {
  @SuppressWarnings("unchecked")
  final Enumeration<Header> en = body.getAllHeaders();

  Header header = en.nextElement();
  final String request =
      header.getName() + (StringUtils.isNotBlank(header.getValue()) ? ":" + header.getValue() : "");

  final Matcher matcher = REQUEST_PATTERN.matcher(request);
  final Matcher matcherRef = BATCH_REQUEST_REF_PATTERN.matcher(request);

  final MultivaluedMap<String, String> headers = new MultivaluedHashMap<String, String>();

  while (en.hasMoreElements()) {
    header = en.nextElement();
    headers.putSingle(header.getName(), header.getValue());
  }

  final Response res;
  final String url;
  final String method;

  if (matcher.find()) {
    url = matcher.group(2);
    method = matcher.group(1);
  } else if (matcherRef.find()) {
    url = references.get(matcherRef.group(2)) + matcherRef.group(3);
    method = matcherRef.group(1);
  } else {
    url = null;
    method = null;
  }

  if (url == null) {
    res = null;
  } else {
    final WebClient client = WebClient.create(url, "odatajclient", "odatajclient", null);
    client.headers(headers);

    if ("DELETE".equals(method)) {
      res = client.delete();
    } else {
      final InputStream is = body.getDataHandler().getInputStream();
      String content = IOUtils.toString(is);
      IOUtils.closeQuietly(is);

      final Matcher refs = REF_PATTERN.matcher(content);

      while (refs.find()) {
        content = content.replace(refs.group(1), references.get(refs.group(1)));
      }

      if ("PATCH".equals(method) || "MERGE".equals(method)) {
        client.header("X-HTTP-METHOD", method);
        res = client.invoke("POST", IOUtils.toInputStream(content));
      } else {
        res = client.invoke(method, IOUtils.toInputStream(content));
      }
    }

    // When updating to CXF 3.0.1, uncomment the following line, see CXF-5865
    // client.close();
  }

  return res;
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:67,代碼來源:Services.java


注:本文中的javax.mail.Header.getValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。