nsSJISProber Class Reference

#include <nsSJISProber.h>

Inheritance diagram for nsSJISProber:
Inheritance graph
[legend]
Collaboration diagram for nsSJISProber:
Collaboration graph
[legend]

Public Member Functions

 nsSJISProber (void)
virtual ~nsSJISProber (void)
nsProbingState HandleData (const char *aBuf, PRUint32 aLen)
const char * GetCharSetName ()
nsProbingState GetState (void)
void Reset (void)
float GetConfidence (void)
void SetOpion ()

Protected Attributes

nsCodingStateMachinemCodingSM
nsProbingState mState
SJISContextAnalysis mContextAnalyser
SJISDistributionAnalysis mDistributionAnalyser
char mLastChar [2]

Detailed Description

Definition at line 52 of file nsSJISProber.h.


Constructor & Destructor Documentation

nsSJISProber::nsSJISProber ( void   )  [inline]

Definition at line 54 of file nsSJISProber.h.

References mCodingSM, Reset(), and SJISSMModel.

00054                     {mCodingSM = new nsCodingStateMachine(&SJISSMModel);
00055                       Reset();};

Here is the call graph for this function:

virtual nsSJISProber::~nsSJISProber ( void   )  [inline, virtual]

Definition at line 56 of file nsSJISProber.h.

References mCodingSM.

00056 {delete mCodingSM;};


Member Function Documentation

const char* nsSJISProber::GetCharSetName (  )  [inline, virtual]

Implements nsCharSetProber.

Definition at line 58 of file nsSJISProber.h.

00058 {return "Shift_JIS";};

float nsSJISProber::GetConfidence ( void   )  [virtual]

Implements nsCharSetProber.

Definition at line 96 of file nsSJISProber.cpp.

References CharDistributionAnalysis::GetConfidence(), JapaneseContextAnalysis::GetConfidence(), mContextAnalyser, and mDistributionAnalyser.

Referenced by HandleData().

00097 {
00098   float contxtCf = mContextAnalyser.GetConfidence();
00099   float distribCf = mDistributionAnalyser.GetConfidence();
00100 
00101   return (contxtCf > distribCf ? contxtCf : distribCf);
00102 }

Here is the call graph for this function:

Here is the caller graph for this function:

nsProbingState nsSJISProber::GetState ( void   )  [inline, virtual]

Implements nsCharSetProber.

Definition at line 59 of file nsSJISProber.h.

References mState.

00059 {return mState;};

nsProbingState nsSJISProber::HandleData ( const char *  aBuf,
PRUint32  aLen 
) [virtual]

Implements nsCharSetProber.

Definition at line 53 of file nsSJISProber.cpp.

References eDetecting, eError, eFoundIt, eItsMe, eNotMe, eStart, GetConfidence(), nsCodingStateMachine::GetCurrentCharLen(), JapaneseContextAnalysis::GotEnoughData(), CharDistributionAnalysis::HandleOneChar(), JapaneseContextAnalysis::HandleOneChar(), mCodingSM, mContextAnalyser, mDistributionAnalyser, mLastChar, mState, nsCodingStateMachine::NextState(), and SHORTCUT_THRESHOLD.

00054 {
00055   nsSMState codingState;
00056 
00057   for (PRUint32 i = 0; i < aLen; i++)
00058   {
00059     codingState = mCodingSM->NextState(aBuf[i]);
00060     if (codingState == eError)
00061     {
00062       mState = eNotMe;
00063       break;
00064     }
00065     if (codingState == eItsMe)
00066     {
00067       mState = eFoundIt;
00068       break;
00069     }
00070     if (codingState == eStart)
00071     {
00072       PRUint32 charLen = mCodingSM->GetCurrentCharLen();
00073       if (i == 0)
00074       {
00075         mLastChar[1] = aBuf[0];
00076         mContextAnalyser.HandleOneChar(mLastChar+2-charLen, charLen);
00077         mDistributionAnalyser.HandleOneChar(mLastChar, charLen);
00078       }
00079       else
00080       {
00081         mContextAnalyser.HandleOneChar(aBuf+i+1-charLen, charLen);
00082         mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen);
00083       }
00084     }
00085   }
00086 
00087   mLastChar[0] = aBuf[aLen-1];
00088 
00089   if (mState == eDetecting)
00090     if (mContextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD)
00091       mState = eFoundIt;
00092 
00093   return mState;
00094 }

Here is the call graph for this function:

void nsSJISProber::Reset ( void   )  [virtual]

Implements nsCharSetProber.

Definition at line 45 of file nsSJISProber.cpp.

References eDetecting, mCodingSM, mContextAnalyser, mDistributionAnalyser, mState, CharDistributionAnalysis::Reset(), JapaneseContextAnalysis::Reset(), and nsCodingStateMachine::Reset().

Referenced by nsSJISProber().

00046 {
00047   mCodingSM->Reset(); 
00048   mState = eDetecting;
00049   mContextAnalyser.Reset();
00050   mDistributionAnalyser.Reset();
00051 }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSJISProber::SetOpion (  )  [inline, virtual]

Implements nsCharSetProber.

Definition at line 62 of file nsSJISProber.h.

00062 {};


Field Documentation

Definition at line 62 of file nsSJISProber.h.

Referenced by HandleData(), nsSJISProber(), Reset(), and ~nsSJISProber().

Definition at line 68 of file nsSJISProber.h.

Referenced by GetConfidence(), HandleData(), and Reset().

Definition at line 69 of file nsSJISProber.h.

Referenced by GetConfidence(), HandleData(), and Reset().

char nsSJISProber::mLastChar[2] [protected]

Definition at line 71 of file nsSJISProber.h.

Referenced by HandleData().

Definition at line 66 of file nsSJISProber.h.

Referenced by GetState(), HandleData(), and Reset().


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208