找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 2829|回复: 10

[webOS开发] Service 的修改方法

[复制链接]
发表于 2009-7-25 17:56 | 显示全部楼层 |阅读模式
谢谢捧场7 i% N2 F- L! Y. E
) x, Y) m2 c8 d- P& m/ ^( I* {3 S
[ 本帖最后由 mfly 于 2009-7-31 16:09 编辑 ]

评分

参与人数 1威望 +50 收起 理由
CyberVsQ + 50 谢谢分享

查看全部评分

回复

使用道具 举报

发表于 2009-7-25 20:59 | 显示全部楼层
支持!!!
回复 支持 反对

使用道具 举报

发表于 2009-7-26 01:04 | 显示全部楼层
谢谢分享
回复 支持 反对

使用道具 举报

发表于 2009-7-26 01:09 | 显示全部楼层
Services 這一个我还是似懂非懂.
回复 支持 反对

使用道具 举报

发表于 2009-7-26 22:17 | 显示全部楼层
用这个方法,结果出现这样,哪里不对呢?请指教,谢谢
  1. package com.palm.messagingrouter;
    - R, @$ y9 f& Y! ?

  2.   }  B/ \, K+ Q1 q5 b7 v
  3. import Association.Many;6 F& d; ^3 A( U7 G" I
  4. import com.palm.oasis.util.ZoneLogger;0 ?4 @7 p" B7 ^7 z8 f2 e2 \

  5. 4 o' ]% C7 i9 Y& U/ S
  6. public class SmsMessageSegmentContainer extends MessageSegmentContainer
    5 |* ]2 w! v2 v+ h
  7.   implements MessagingRouterJsonConstants, MessagingRouterTilConstants
      {1 A8 Y6 C# L. r% H( S1 g' P
  8. {
    % `- a+ [! h2 y5 n7 C
  9.   private static final long serialVersionUID = 1L;6 I& e/ B; U% L% a( y
  10.   private String completeMsgString;( }" C3 r( i; i0 N
  11.   private String bodyEncoding;& V5 y6 S' a$ E
  12.   protected static ZoneLogger logger;
    ! g7 C. X9 N1 a  c# g& x! ], ?) M
  13.   Many segments;
    2 Y  {* H8 O  {& D; A+ h# e  B

  14. ; A- g7 L* v, f  U2 m5 n# N
  15.   public SmsMessageSegmentContainer()
    " h) D0 f0 T& m5 C1 O+ G
  16.   {
    4 U' D4 I7 q3 H1 k% F
  17.   }( A/ J/ u1 b' |1 \* P, n& N# h
  18. ; `  f+ W6 O1 U
  19.   public SmsMessageSegmentContainer(long messageId, int totalSegments, String bodyEncoding)
    ) M8 l- N: O9 d& [( a9 L
  20.   {
    . r" E  O7 S" x9 Y
  21.   }1 W% q5 B; c- B  o

  22. 5 l) e: G. I1 C1 W
  23.   SmsMessageSegmentContainer(String messageId, int totalSegments, String bodyEncoding)
    4 j( V6 t8 V) U- Q2 r
  24.   {
      O; m  N0 c4 a  q/ T% a- Z; r
  25.   }% E# u; r: X+ J* n0 l1 [

  26. . X! e' R  n# u7 |5 \
  27.   public String getBodyEncoding()
    $ ^6 N* a$ s8 P3 L/ B
  28.   {+ T( s+ K2 X9 C1 D7 E( @
  29.     throw new Error("Unresolved compilation problem: \n");
    % E9 u( T/ Y$ k8 A+ {
  30.   }$ @' u9 r1 _: `1 K3 z: f
  31. 1 J) _# @, `6 n( L) L7 O7 R2 K4 d4 E
  32.   protected boolean isPrintableChar(char ch)
    2 `9 {& X% D- n' |
  33.   {
    ; \& \0 m3 c6 d  T) [4 k0 n3 X
  34.     throw new Error("Unresolved compilation problem: \n");
    7 W6 v) n% d5 p9 i
  35.   }
    ; C3 ]+ x2 e; e# k* R7 I0 j/ G, N
  36. 7 A9 p) _5 ^3 w
  37.   public boolean isMessageComplete(), R/ Z- g# }, I8 o
  38.   {7 q5 l- p% C& h  d8 s- H( Q
  39.     throw new Error("Unresolved compilation problem: \n\tMany cannot be resolved to a type\n");
    , ~& S0 @  e% E
  40.   }" {3 F/ y- ]0 O

  41. 5 E+ T" B: j' S. }+ `
  42.   public String getCompletedBody()8 E& m  \5 C8 |; h" O/ _+ m) D
  43.   {
    1 w2 t4 h  r8 z2 w/ d2 b
  44.     throw new Error("Unresolved compilation problem: \n");- _3 c) V) X  ]! x$ ~
  45.   }
    % y3 v" ~9 w$ l

  46. # G' F2 Q) D' o: i1 F+ R% J
  47.   public void addNewSegment(SmsMessageFromTil msgSegment)# \( x; V) S, u7 X1 Z5 b' i1 j
  48.   {
    # S; o. N8 ?- K' n
  49.     throw new Error("Unresolved compilation problems: \n\tMany cannot be resolved to a type\n\tMany cannot be resolved to a type\n");8 _: F4 |+ E+ r( e
  50.   }
    * Z/ {" }  A: c2 k/ M

  51. 0 t( j8 \! v3 o% q
  52.   private String convertToJson(boolean doHidePrivateData)# a6 d6 N9 h( T6 V1 L
  53.   {9 D$ p& [# X; m* x+ W5 G7 Z: s) R
  54.     throw new Error("Unresolved compilation problems: \n\tMany cannot be resolved to a type\n\tSyntax error on token ":", ; expected\n\tSyntax error, insert "AssignmentOperator Expression" to complete Assignment\n\tSyntax error, insert ";" to complete Statement\n\tString cannot be resolved\n\tjsonString cannot be resolved\n\tjsonString cannot be resolved\n\tjsonString cannot be resolved\n");
    2 k; }- w5 L* }8 ~- ^3 r+ h
  55.   }/ c/ v$ ?3 h% H5 Q6 n1 B, @
  56. - s. b. Q. ~$ W1 @% W* G! u2 E7 n# s
  57.   public String toJSONString()8 b% D5 U( ]3 Z1 [8 i; n: {5 v! I9 P
  58.   {
    3 ~7 a2 i8 r+ x; y, |4 R
  59.     throw new Error("Unresolved compilation problem: \n");
    $ }, u$ u1 Y6 z" {% ]5 x# u; J4 h
  60.   }
      N1 q- J& L5 \! S  E/ o8 Q

  61. / v) B/ U% t+ m
  62.   public String toDebugJSONString()1 }  N. q3 \/ N" T: G
  63.   {
    6 b, ~. @" a6 e# j2 p+ P
  64.     throw new Error("Unresolved compilation problem: \n");
    ' }  m% k; a. t6 T- G
  65.   }2 W; q- Q# E! s
  66. }
复制代码
回复 支持 反对

使用道具 举报

发表于 2009-7-26 22:23 | 显示全部楼层

原始代码是这样的

  1. package com.palm.messagingrouter;
    % K* Y- Q7 |/ E0 S

  2. & J7 L0 Q5 }/ j, a4 s4 f) b/ `! e$ a
  3. import com.palm.oasis.activerecord.ActiveRecord;& ~. T0 V6 ?& ]  }4 c5 Y
  4. import com.palm.oasis.activerecord.ActiveRecordException;
    / ~, u% u7 l9 b5 U" b# b$ u4 V7 i
  5. import com.palm.oasis.activerecord.Association.Many;
    - S* [% ^& o* |
  6. import com.palm.oasis.activerecord.Batch;
    5 T5 c: B4 ~5 w
  7. import com.palm.oasis.activerecord.SqlFind;  G7 l9 h. z4 c5 k' z% N" a
  8. import com.palm.oasis.util.Base64;
    3 N* z# a' |9 @0 S- P. T: w: ?
  9. import com.palm.oasis.util.ServiceLogger;
    1 S8 \9 }5 v/ F8 q
  10. import com.palm.oasis.util.ZoneLogger;
    ( Y/ j5 }1 I: w* |
  11. import java.io.ByteArrayOutputStream;
    1 ^+ [9 z0 M& \+ W+ u8 t% a
  12. import java.io.IOException;
    ! E# d( u( f! j/ g- F
  13. import java.io.PrintStream;* m1 z) z8 A, O) a$ ^- g, c
  14. import java.util.Iterator;  o  N5 q- o$ d& }2 X. Q
  15. import java.util.List;
    ( x% c  j4 \, u
  16. import org.json.JSONException;# e  U/ ]" A" Z% n
  17. import org.json.JSONObject;
    2 U# X' A+ R" {. {* c2 \9 v- p

  18. # ?, \8 u% K; X) [; `2 v: C- `
  19. public class SmsMessageSegmentContainer extends MessageSegmentContainer" ?( y2 l) j( }, ^8 R- m
  20.   implements MessagingRouterJsonConstants, MessagingRouterTilConstants! ?" ^' j  c- D  w8 S
  21. {* c7 |( Z0 G$ X# E; r, a  I
  22.   private static final long serialVersionUID = 1L;( X: L% G* S8 M- t" A
  23.   private String completeMsgString;$ M5 k4 y) ~% G3 E0 p/ x& V+ I
  24.   private String bodyEncoding;
    + E; |0 E9 O& H5 \( _" Z; u5 N
  25.   protected static ZoneLogger logger = MessagingRouterService.getLogger(SmsMessageSegmentContainer.class.getSimpleName());, Q) m+ B. |/ n8 b: e* O7 h
  26.   Association.Many segments;
    6 T# n" x7 V3 l2 F6 k
  27. ) k) x" a2 E1 B+ l
  28.   public SmsMessageSegmentContainer()
    7 b" B) I% |) c3 v" T
  29.   {9 w4 @. k: a+ X; C# m5 C
  30.     this.completeMsgString = null;# o8 c, t  Y2 B  F, h+ G
  31.     this.bodyEncoding = null;, p' P1 E1 e* i4 K
  32.     this.segments = hasMany(SmsMessageFromTil.class, 1);
    9 }' P- B5 }8 `, T  d/ q+ L$ z! B
  33.   }3 W* l$ o  S4 C- |# f2 M) E4 |

  34. / b' H2 w, G2 u/ g/ t: @# \
  35.   public SmsMessageSegmentContainer(long messageId, int totalSegments, String bodyEncoding)
    2 E6 i3 e9 |! A( |: c! J) H. ~
  36.   {
    : N3 R" F  f5 W) j8 p; j$ n
  37.     super(System.currentTimeMillis(), messageId, totalSegments);
    , Z! g4 X0 \3 i5 ?
  38.     this.completeMsgString = null;
    1 o. t" v% J# y8 E* D2 l& a0 M
  39.     this.bodyEncoding = null;; M& e: `$ ]9 ]  W# F
  40.     this.segments = hasMany(SmsMessageFromTil.class, 1);
    - W& ~4 V7 i6 w
  41.     this.bodyEncoding = bodyEncoding;, O* v+ B- G! m( q  p  i8 L! `5 z
  42.   }
    5 x9 v, z& O6 s; l4 Q

  43. 9 y% ~3 O9 i8 j# |3 `; j7 s
  44.   SmsMessageSegmentContainer(String messageId, int totalSegments, String bodyEncoding)/ s0 R, L; z( M( S
  45.   {
    9 \7 n/ D! w+ U+ _. w) m
  46.     super(System.currentTimeMillis(), Integer.parseInt(messageId), totalSegments);
    # e! W8 k8 i+ ~5 |) S; [% Z
  47.     this.completeMsgString = null;9 j9 Q# S9 m0 `: I& `
  48.     this.bodyEncoding = null;
    ; K. q& H+ Z: ]  R% y7 o
  49.     this.segments = hasMany(SmsMessageFromTil.class, 1);
    5 d4 ~" G; r, `( J* ^: J8 V* \
  50.     this.bodyEncoding = bodyEncoding;
    8 u2 p. @/ G( Z5 Z% t; u2 o! V
  51.   }) j7 W: v1 m" V& s

  52. 6 M7 G  x1 i1 g7 F
  53.   public String getBodyEncoding()
    9 ^2 x# [1 T; M7 V1 D# q. {
  54.   {( }3 W1 W: F7 `  q
  55.     return this.bodyEncoding;: `2 M; u, ?1 t1 q. Y: q) q8 y& C5 u
  56.   }
    & b' Y  N5 \. b) m" C
  57. # T6 e9 s; G* s9 {0 K$ u  z4 U/ T. v
  58.   protected boolean isPrintableChar(char ch)1 b/ u0 O$ @- A5 {! ?
  59.   {& X. N; F* J# T6 W! Z' A/ D
  60.     boolean isItPrintableChar = false;9 E8 W0 O: `* _2 A- i
  61.     if ((ch >= ' ') && (ch <= '~')) {( @% v& O' e" S& q, w
  62.       isItPrintableChar = true;( n1 p3 Z' x8 ?. c8 ?
  63.     }
    6 p$ K' g6 L2 I% x+ W2 u+ H1 L( I
  64.     else if ((ch >= 128) && (ch <= 168)) {
    % A( E$ w) e( {/ \/ R
  65.       isItPrintableChar = true;
    8 Y" _5 R/ @& j1 G' E
  66.     }
    1 Y' M( b& v( s4 o; M/ }
  67.     else if ((ch >= 224) && (ch <= 247))0 z8 m0 T9 Z. B/ X/ B( E
  68.       isItPrintableChar = true;# W& t" U! }6 p
  69.     return isItPrintableChar;
    / T  P" \' F7 f5 G$ d! y$ g
  70.   }
    : c$ s! q1 ~; V5 q5 B. u) y

  71. 4 d9 W  x2 K5 A" s5 M9 b! |
  72.   public boolean isMessageComplete()
    3 L5 ~% a/ k; Z4 d+ F- q
  73.   {5 @2 Q, ~9 i3 L
  74.     if (!(this.isMessageComplete))! X! k8 W9 |2 X! [) H
  75.       try
    - Q" D9 g1 Z: S& R1 I1 b3 t4 c
  76.       {$ b# J; l  N% ^5 M- r
  77.         synchronized (SmsMessageSegmentContainer.class)5 N% U6 }$ f' V- ]+ w
  78.         {
    # }# ^) k  G. `- F4 U  I
  79.           List listSmsSegments = ActiveRecord.find(this.segments.sqlAll().orderBy("segmentNumber ASC"));4 j1 |3 A! G# I' q$ C6 K
  80.           if ((listSmsSegments != null) && (listSmsSegments.size() == this.totalSegments))' j8 @, A% n" J: m8 o# q3 p
  81.           {" ~& k6 R5 K. U% c7 X2 ?
  82.             this.isMessageComplete = true;/ N/ c1 r8 Z* L; G2 O9 k
  83.             logger.fine("At this point all SMS message segments have been recieved so we are going to put it all together");
    " x. z7 h0 s; t/ [$ m; y& \
  84.             StringBuilder msgString = new StringBuilder(160 * this.totalSegments);8 T% A- q# N9 n0 c7 z
  85.             if (msgString != null)
    - {1 V% y# s1 V, J* `, h: N3 h
  86.             {3 R) A, m7 H( c" k, `
  87.               if ("bbin".equals(this.bodyEncoding))4 Y' R0 O+ V3 B
  88.               {
    & m3 o8 j) Z% q
  89.                 ByteArrayOutputStream byteOut = new ByteArrayOutputStream();9 o" v! [, M+ V$ r
  90.                 Iterator i$ = listSmsSegments.iterator();
    9 I  v. G7 [( R6 o
  91. % q5 ?& ^$ G0 C/ s; U: z
  92.                 while (i$.hasNext())7 c/ j; I1 ?; _0 h( B; Q, c
  93.                 {% Z0 j. D1 y9 k& w
  94.                   SmsMessageFromTil msg = (SmsMessageFromTil)i$.next();6 O/ ^! G0 O, n( |
  95.                   if ((msg.getBody() != null) && (msg.getBody().length() != 0));2 p$ I8 _  r; E! Y9 j$ Q+ [: C
  96.                   byteOut.write(Base64.decode(msg.getBody()));: p. v' R2 N3 U! R7 V. l7 K( `
  97.                 }. k2 r  r" _% W
  98.                 char[] testArray = byteOut.toString().toCharArray();* n* g5 ^- b5 l4 V
  99.                 boolean isAllCharsPrintable = true;& O3 J2 W+ ^  v2 {" O
  100.                 int i = 0;$ c. n! m; G7 r
  101.                 for (i = 0; (i < testArray.length) && (isAllCharsPrintable); ++i) {
    6 Y- W+ I+ Y/ e+ W
  102.                   if (!(isPrintableChar(testArray[i])))2 C! `' }. E: n2 V0 @4 d
  103.                     isAllCharsPrintable = false;. D9 S- P8 Q& @- q: g2 }
  104.                 }9 _$ H& |% T. Z
  105.                 if (isAllCharsPrintable)
    3 S8 C2 y1 m7 o/ |
  106.                   this.completeMsgString = byteOut.toString() + "";$ x6 Z0 S& i( n( F0 y& z
  107.                 else8 D7 h# P; u% P: z2 e% M
  108.                   this.completeMsgString = Base64.encodeBytes(byteOut.toByteArray()) + "";
    9 r1 L4 Y% t7 t2 {
  109.                 System.out.println(this.completeMsgString);
    ) p) n: j) \; J/ h( ^: K; p2 W
  110.               }
    ( |; n/ c1 \2 a
  111.               else {- }* O- e) M) g9 `! |
  112.                 Iterator i$ = listSmsSegments.iterator();
    ' B* t' A3 x  @
  113. # U" U6 x+ r% Y! k8 z
  114.                 while (i$.hasNext())
    - S% `1 W8 D- j$ |- M2 l% |
  115.                 {
      B5 q- K$ r0 B8 C7 P. v6 s0 @( R
  116.                   SmsMessageFromTil msg = (SmsMessageFromTil)i$.next();
    5 X$ `5 P: N1 j7 `% e* \4 A1 c
  117.                   if ((msg.getBody() != null) && (msg.getBody().length() != 0));& U0 {+ y% X1 G: E7 B9 {
  118.                   msgString.append(TilUtils.decodeString(msg.getBodyEncoding(), msg.getBody()));+ {* W+ [! b# J3 o; U9 \
  119.                 }$ p6 _/ z, F; ~" E2 B& N
  120.                 this.completeMsgString = msgString.toString() + "";( g& h* G7 z9 J! }, m
  121.               }5 Z0 t7 U, a4 m: m3 y* ^$ d5 ~
  122.             }
    % g+ M& w" [- x; l
  123.             else {
    ( r9 @; g# b6 j: X6 r
  124.               logger.severe("Error allocating memory to put Segmented SMS Message Together");
    / a" D+ c; K8 q
  125.             }
    ( j6 y5 X4 ~7 k( L
  126.           }
    + _3 e% v- L1 a0 n
  127.           else if ((listSmsSegments != null) && (listSmsSegments.size() > this.totalSegments)) {5 n- D, Y/ R- [
  128.             logger.severe("Too many SMS message segments found so assuming corrupted for " + this.segMsgContainerId + " in DB.  We found:" + listSmsSegments.size() + " but we expected: " + this.totalSegments); }, J8 [" M# m( B8 O
  129.           listSmsSegments = null;# |+ W8 ]: P! c8 H% _
  130.         }
    . K/ l. O: \0 h3 @0 i6 i
  131.       }2 P  t* {& J! [6 _
  132.       catch (ActiveRecordException e)
    # R  q! j1 Q8 o
  133.       {( R; e7 ^  @' V! h" J
  134.         logger.warning("SMS Message couldn't be retrieved from the database at this time.");" w3 R6 i4 n) _' Y5 c+ Y/ J
  135.       }
    , l6 q# I& R6 x4 Z0 Z- v
  136.       catch (NullPointerException e). p- d3 g+ w" Q# V9 @! ~, C5 W
  137.       {2 U3 ~2 v2 h4 p9 K
  138.         logger.severe("Null Pointer Error putting Segmented SMS Message Together");
      B  q+ M0 i. Y" [
  139.       }
    7 U7 t% A$ J9 r1 d( O! s$ i9 ]6 D
  140.       catch (IOException e)" Z0 X, F, v9 h6 L% S* n
  141.       {
    + }; R6 R$ @& c* x. C/ T5 y
  142.         logger.severe("Error Decoding Binary Message");
    ( C; f6 V2 f, Q' t; J1 S3 g
  143.       }
    4 J. `5 I4 m3 H
  144.     return this.isMessageComplete;
    + F. N6 L+ W. f+ M
  145.   }
    : L5 b; i8 V3 N. ?' q

  146. - j4 C% v( u& f4 z1 I; X
  147.   public String getCompletedBody()
      {) l, k! V  D& R% ?
  148.   {' z8 Q2 _! |8 v2 I, m# z
  149.     if (!(isMessageComplete()))
    1 d, Q4 a( `" u+ l( n* ~: {
  150.       logger.warning("Message Not yet Complete so you should call this after testing with isMessageComplete");. w: E3 e0 L! T5 E8 P$ y! Z0 A
  151.     return this.completeMsgString;# ^& j2 q3 G; C- L* s
  152.   }
    . M! J) v" A" F" f# Y
  153. , }3 _' i: F% I" P  {
  154.   public void addNewSegment(SmsMessageFromTil msgSegment)
    4 `. y! ?. H9 p- F, g; O
  155.   {
    3 m6 y2 f) D* Y" ]3 F7 {
  156.     try
    : {! T# U3 v! O7 W/ g, |) b7 e
  157.     {
    0 L% P4 _0 W0 m* [* U2 K
  158.       if (logger.getLogger().isFinerLoggable)
    3 B- I! I) J8 ~) e: Q% _$ q  o
  159.         logger.finer("Attempting to Adding new SMS Message with MessageId:" + msgSegment.getMessageId() + " with SegmentNo:" + msgSegment.getSegmentNumber() + " of Total Segments:" + msgSegment.getTotalNumberOfSegments());# G  I/ K" _1 g3 B
  160.       synchronized (SmsMessageSegmentContainer.class)6 W3 X7 m  s+ K
  161.       {, D. ^! e/ l$ V( `# @
  162.         int numSegmentsAlreadyStoredWithThatSegNumber = ActiveRecord.count(this.segments.sqlAll().where("segmentNumber=?", new Object[] { 1 u  H; ~8 }8 ]4 V9 j4 L( Z- X
  163.           Integer.valueOf(msgSegment.getSegmentNumber()) }));
    5 {9 w& c7 `: `5 I
  164. / i4 u+ F  ^' ?7 c  R' B2 @1 g
  165.         if (numSegmentsAlreadyStoredWithThatSegNumber == 0)
    & R& M4 ]8 n' l- R, I) x9 X
  166.         {
    + R& ?6 v2 u; A
  167.           logger.finer("New SMS Segmeted Accepted.  Adding it to SMS Container");
    5 y$ ~+ U& g: H5 _
  168.           logger.finer("saving segment to message holder");
    - h1 Q5 r2 z- z; ~
  169.           Batch batch = new Batch();) y: M& A& \+ f+ {& [9 I' V9 @5 u
  170.           this.segments.push(batch, msgSegment);: T% y* M9 B! g) s+ a! F
  171.           msgSegment.save(batch);
    % M3 h0 k( }% C/ T: a" }
  172.           if (0L != msgSegment.getTimeStamp())& k. V8 c9 c5 b
  173.             setTimeStampLastReceivedSegment(msgSegment.getTimeStamp());
    & g( t- [9 W. u
  174.           save(batch);5 p- ]& K/ D. S. a! V4 i. v
  175.           batch.execute();
    7 Y7 A6 V: Y% i4 |
  176.         }# k8 L  R9 _+ F8 x; }3 }, m
  177.         else {
    ' x3 E5 P5 i' ^+ e+ ^0 {6 R
  178.           logger.warning("Found duplicate SMS Message segment already saved");
    0 @0 t4 F6 o! |. R
  179.         }
    % A/ A, A- `0 e9 ^+ |" S6 k% B5 Q. Y
  180.       }7 L1 V7 ]7 F8 @! j
  181.     }4 t0 f0 x# ~& I' v* ~: M' S* M2 T
  182.     catch (ActiveRecordException e)
    4 \9 j! D6 c# n
  183.     {% q3 A6 e6 H/ t# z' V. A. [" L
  184.       logger.severe("Error saving SMS Message Segment.  Data will probably be lost.");1 x6 e+ f+ Q" e3 I6 {! T% R
  185.     }
    4 o; t8 U4 y; x$ c# p. V9 s8 v# v, r
  186.   }
    $ k! |! f  G' R0 v! [2 S. x9 k

  187. 0 G* h9 O5 K9 Y2 w: S
  188.   private String convertToJson(boolean doHidePrivateData)
    5 v! `! A6 c8 r/ H  Q3 v& [
  189.   {
    . S- o9 L1 P! v; ~' i$ S; Y
  190.     JSONObject smsJson = new JSONObject();
    0 V* l  s$ r4 w* D% G
  191.     SmsMessageFromTil msgSeg = null;
    5 E* I. b5 C  |) C2 `
  192.     try3 {$ ]: D# c4 B$ j
  193.     {2 S3 }4 `$ |. s" G
  194.       msgSeg = (SmsMessageFromTil)this.segments.findFirst();! X6 T4 r( D& a, t( j' s
  195.       if (msgSeg != null). m, p  R1 s/ i5 V# i# t* h* W0 s4 N
  196.       {
    ' ]+ w' `' D9 ~1 x' R
  197.         if (doHidePrivateData)" k  y( F9 o& G! O. w% [
  198.         {7 P- Z4 O0 n8 X" q2 ^6 I" G
  199.           smsJson.put("body", "This has been hidden for logging");6 U( w' c: L% l
  200.           smsJson.put("address", "555-333-4444");
    # c- a# g4 R8 G: V9 f
  201.           smsJson.put("callbackNumber", "555-333-4444");
    / ]! _3 B$ W0 o( \: U, [. m
  202.         }! L. x8 z- u1 y& ]
  203.         else {3 e8 `" e8 a: @1 f8 O
  204.           smsJson.put("body", getCompletedBody());4 w; Y+ ?5 y! a
  205.           smsJson.put("address", msgSeg.getWhoIsItFrom());. G: `+ ^$ p* ]: n: N& N
  206.           smsJson.put("callbackNumber", msgSeg.getCallbackNumber());
    * s/ ~9 L& N* U' R
  207.         }
    / \0 j# K" ?8 n. m/ Q+ d* M
  208.         smsJson.put("networkMsgId", msgSeg.getMessageId());/ g: h  O- t5 ~7 P* d; K# ]7 Q" v# b  Z
  209.         smsJson.put("deliveryReportOptions", msgSeg.getDeliveryReportOptions());" K2 O1 Q2 k; |8 V% Y
  210.         smsJson.put("timeStamp", msgSeg.getTimeStamp());9 {# n; k4 A: G4 t- B
  211.         if (msgSeg.isThisMessageFromAGsmNetwork())
    0 i" @& e) x1 h3 g
  212.         {. w, j+ x. F5 Q5 ?# h0 U9 O  x
  213.           smsJson.put("priority", msgSeg.getSmsClassInfo());
    3 g  u7 P# r: v( Z0 U
  214.           if (msgSeg.isFromSim())8 {' N; U% @1 F0 p8 q( ~: [
  215.             smsJson.put("isFromSim", true);
    6 _7 l' Z, d7 Y1 c' |
  216.         }' B2 e: {5 M& o* u  l" D8 J2 O
  217.         else {1 K% ?4 g, S* M7 P; S* W  s; R
  218.           smsJson.put("priority", msgSeg.getPriority());$ w' H8 A. {, C8 G9 s4 R# u) t
  219.         }8 c+ ^/ B: v" |( |
  220.         smsJson.put("displayMode", msgSeg.getDisplayMode());
      k0 j; i7 Q1 U+ x; o
  221.         smsJson.put("privacyMode", msgSeg.getPrivacyMode()); break label257:- Z* J# r6 ^0 U/ ?6 G: ]/ n! x8 t9 ^- g
  222.       }- J. p" z  ?' B- j3 a
  223. ' j3 a* _* p9 p0 D  D9 J2 V+ Q
  224.       logger.severe("Did not find Message Segment to generate JSON string");% [0 J: I6 p0 J9 A
  225.     }2 s; Y5 L( Y0 t7 _7 K$ [- ^
  226.     catch (ActiveRecordException e)
    9 j  r( Y& P4 u3 ^0 u, L5 n5 D" G
  227.     {
    7 w& q' i2 p( [; S% }
  228.       logger.severe("Caught Exception", e);
    % c) q* I8 i$ `# h$ H& i0 O
  229.     }% `, o- u1 ?0 w% ?) h
  230.     catch (JSONException e)6 L* L) ~, k+ [0 f+ g* z
  231.     {9 T' R1 i+ {  Z& B
  232.       logger.severe("Caught Exception", e);8 @) h+ t, T, c. b7 d! D7 @' c+ {* l
  233.     }+ i. o; X% b+ }3 J& o4 @
  234.     label257: String jsonString = smsJson.toString();
    ) T9 ~8 q5 Q. B0 u4 |
  235.     logger.finer("toJSONString SMS Message: " + jsonString);$ H. Z8 |' a/ u2 P1 N3 Z: U0 J
  236.     return jsonString;6 f- g+ ~( D2 l; g6 S
  237.   }
    4 }" n  B* H- K( J

  238. * _, S& a' @) Z+ d
  239.   public String toJSONString()
    + @" W, f" h2 Y0 l2 O
  240.   {
    + w! A# A* K3 o6 T8 V/ p9 F- U
  241.     return convertToJson(false);
      P0 g* X1 n' O; p3 H. u
  242.   }
    + y' @, g8 H  I4 y+ M4 {* N& W
  243. " h( X( ]5 p$ i$ ]- f% U* t4 q
  244.   public String toDebugJSONString()
    9 Z1 Y7 b" p! d. m# [6 U
  245.   {) S1 }2 f9 U9 {, ?3 _
  246.     return convertToJson(true);, V5 b7 J$ i) f( K! c* D8 T) C" ^
  247.   }  ~2 K. v: ^. E( x9 o, _( A' ~
  248. }
复制代码
回复 支持 反对

使用道具 举报

发表于 2009-7-26 22:23 | 显示全部楼层

回复 楼主1# mfly 的帖子

我把palm的Jar也都加入Library了啊,咋回事呢?报了好多错哎
回复 支持 反对

使用道具 举报

发表于 2009-7-26 22:50 | 显示全部楼层

回复 楼主1# mfly 的帖子

是不是因为我加入的是1.1ROM里的jar的关系呢?跟1.0.4的参数对不上了
回复 支持 反对

使用道具 举报

发表于 2009-7-27 00:28 | 显示全部楼层

回复 楼主1# mfly 的帖子

我试了下,编译你的那个文件就ok,我编译的是SmsMessageSegmentContainer,不灵,估计是SmsMessageSegmentContainer里面的一些函数在library里找不到吧,如何才能编译这个文件成功呢?请指点一下,谢谢
回复 支持 反对

使用道具 举报

发表于 2009-7-27 21:24 | 显示全部楼层
eclipse啊~像我们这种穷人,只能用Emacs....
回复 支持 反对

使用道具 举报

发表于 2009-8-18 22:01 | 显示全部楼层
其它的代码有吗?我用jd-gui 0.2.7反编译出来好像有点问题啊。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|Archiver|手机版|小黑屋|吹友吧 ( 京ICP备05078561号 )

GMT+8, 2024-11-21 00:14 , Processed in 0.331982 second(s), 18 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表