代码4.docx

上传人:b****6 文档编号:5618229 上传时间:2022-12-29 格式:DOCX 页数:97 大小:35.66KB
下载 相关 举报
代码4.docx_第1页
第1页 / 共97页
代码4.docx_第2页
第2页 / 共97页
代码4.docx_第3页
第3页 / 共97页
代码4.docx_第4页
第4页 / 共97页
代码4.docx_第5页
第5页 / 共97页
点击查看更多>>
下载资源
资源描述

代码4.docx

《代码4.docx》由会员分享,可在线阅读,更多相关《代码4.docx(97页珍藏版)》请在冰豆网上搜索。

代码4.docx

代码4

packageorg.hibernate.c3p0.internal;

packagecom.steadystate.css.parser;

importcom.steadystate.css.parser.selectors.ConditionFactoryImpl;

importcom.steadystate.css.parser.selectors.SelectorFactoryImpl;

importcom.steadystate.css.sac.DocumentHandlerExt;

importjava.io.IOException;

importjava.io.InputStreamReader;

import.URL;

importjava.nio.charset.Charset;

importjava.text.MessageFormat;

importjava.util.Locale;

importjava.util.MissingResourceException;

importjava.util.ResourceBundle;

importorg.w3c.css.sac.CSSParseException;

importorg.w3c.css.sac.ConditionFactory;

importorg.w3c.css.sac.DocumentHandler;

importorg.w3c.css.sac.ErrorHandler;

importorg.w3c.css.sac.InputSource;

importorg.w3c.css.sac.LexicalUnit;

importorg.w3c.css.sac.Locator;

importorg.w3c.css.sac.Parser;

importorg.w3c.css.sac.SACMediaList;

importorg.w3c.css.sac.Selector;

importorg.w3c.css.sac.SelectorFactory;

importorg.w3c.css.sac.SelectorList;

abstractclassAbstractSACParser

implementsParser

{

privateDocumentHandlerdocumentHandler_;

privateErrorHandlererrorHandler_;

privateInputSourcesource_;

privateLocalelocale_;

privateSelectorFactoryselectorFactory_;

privateConditionFactoryconditionFactory_;

privateResourceBundlesacParserMessages_;

privatestaticfinalStringNUM_CHARS="0123456789.";

protectedabstractTokengetToken();

protectedDocumentHandlergetDocumentHandler()

{

if(this.documentHandler_==null){

setDocumentHandler(newHandlerBase());

}

returnthis.documentHandler_;

}

publicvoidsetDocumentHandler(DocumentHandlerhandler){

this.documentHandler_=handler;

}

protectedErrorHandlergetErrorHandler(){

if(this.errorHandler_==null){

setErrorHandler(newHandlerBase());

}

returnthis.errorHandler_;

}

publicvoidsetErrorHandler(ErrorHandlereh){

this.errorHandler_=eh;

}

protectedInputSourcegetInputSource(){

returnthis.source_;

}

publicvoidsetLocale(Localelocale){

if(this.locale_!

=locale){

this.sacParserMessages_=null;

}

this.locale_=locale;

}

protectedLocalegetLocale(){

if(this.locale_==null){

setLocale(Locale.getDefault());

}

returnthis.locale_;

}

protectedSelectorFactorygetSelectorFactory(){

if(this.selectorFactory_==null){

this.selectorFactory_=newSelectorFactoryImpl();

}

returnthis.selectorFactory_;

}

publicvoidsetSelectorFactory(SelectorFactoryselectorFactory){

this.selectorFactory_=selectorFactory;

}

protectedConditionFactorygetConditionFactory(){

if(this.conditionFactory_==null){

this.conditionFactory_=newConditionFactoryImpl();

}

returnthis.conditionFactory_;

}

publicvoidsetConditionFactory(ConditionFactoryconditionFactory){

this.conditionFactory_=conditionFactory;

}

protectedResourceBundlegetSACParserMessages(){

if(this.sacParserMessages_==null){

try{

this.sacParserMessages_=ResourceBundle.getBundle("com.steadystate.css.parser.SACParserMessages",getLocale());

}

catch(MissingResourceExceptione)

{

e.printStackTrace();

}

}

returnthis.sacParserMessages_;

}

publicLocatorgetLocator(){

returncreateLocator(getToken());

}

protectedLocatorcreateLocator(Tokent){

returnnewLocatorImpl(getInputSource().getURI(),t==null?

0:

t.beginLine,t==null?

0:

t.beginColumn);

}

protectedStringadd_escapes(Stringstr)

{

StringBuildersb=newStringBuilder();

if((ch<'')||(ch>'~')){

Strings="0000"+Integer.toString(ch,16);

sb.append("\\u"+s.substring(s.length()-4,s.length()));

}

else{

sb.append(ch);

}

break;

}

}

returnsb.toString();

}

protectedCSSParseExceptiontoCSSParseException(Stringkey,ParseExceptione){

StringmessagePattern1=getSACParserMessages().getString("invalidExpectingOne");

StringmessagePattern2=getSACParserMessages().getString("invalidExpectingMore");

intmaxSize=0;

StringBuilderexpected=newStringBuilder();

for(inti=0;i

if(maxSize

maxSize=e.expectedTokenSequences[i].length;

}

for(intj=0;j

expected.append(e.tokenImage[e.expectedTokenSequences[i][j]]);

}

if(i

expected.append(",");

}

}

StringBuilderinvalid=newStringBuilder();

Tokentok=e.currentToken.next;

for(inti=0;i

if(i!

=0){

invalid.append("");

}

if(tok.kind==0){

invalid.append(e.tokenImage[0]);

break;

}

invalid.append(add_escapes(tok.image));

tok=tok.next;

}

Strings=null;

try{

s=getSACParserMessages().getString(key);

}

catch(MissingResourceExceptionex){

s=key;

}

StringBuildermessage=newStringBuilder(s);

message.append("(");

if(e.expectedTokenSequences.length==1){

message.append(MessageFormat.format(messagePattern1,newObject[]{invalid,expected}));

}

else{

message.append(MessageFormat.format(messagePattern2,newObject[]{invalid,expected}));

}

message.append(")");

returnnewCSSParseException(message.toString(),getInputSource().getURI(),e.currentToken.next.beginLine,e.currentToken.next.beginColumn);

}

protectedCSSParseExceptiontoCSSParseException(TokenMgrErrore)

{

StringmessagePattern=getSACParserMessages().getString("tokenMgrError");

returnnewCSSParseException(messagePattern,getInputSource().getURI(),1,1);

}

protectedCSSParseExceptiontoCSSParseException(StringmessageKey,Object[]msgParams,Locatorlocator)

{

StringmessagePattern=getSACParserMessages().getString(messageKey);

returnnewCSSParseException(MessageFormat.format(messagePattern,msgParams),locator);

}

protectedCSSParseExceptioncreateSkipWarning(Stringkey,CSSParseExceptione){

Strings=null;

try{

s=getSACParserMessages().getString(key);

}

catch(MissingResourceExceptionex){

s=key;

}

returnnewCSSParseException(s,e.getURI(),e.getLineNumber(),e.getColumnNumber());

}

publicvoidparseStyleSheet(InputSourcesource)throwsIOException{

this.source_=source;

ReInit(getCharStream(source));

try{

styleSheet();

}

catch(ParseExceptione){

getErrorHandler().error(toCSSParseException("invalidStyleSheet",e));

}

catch(TokenMgrErrore){

getErrorHandler().error(toCSSParseException(e));

}

catch(CSSParseExceptione){

getErrorHandler().error(e);

}

}

publicvoidparseStyleSheet(Stringuri)throwsIOException{

parseStyleSheet(newInputSource(uri));

}

publicvoidparseStyleDeclaration(InputSourcesource)throwsIOException{

this.source_=source;

ReInit(getCharStream(source));

try{

styleDeclaration();

}

catch(ParseExceptione){

getErrorHandler().error(toCSSParseException("invalidStyleDeclaration",e));

}

catch(TokenMgrErrore){

getErrorHandler().error(toCSSParseException(e));

}

catch(CSSParseExceptione){

getErrorHandler().error(e);

}

}

publicvoidparseRule(InputSourcesource)throwsIOException{

this.source_=source;

ReInit(getCharStream(source));

try{

styleSheetRuleSingle();

}

catch(ParseExceptione){

getErrorHandler().error(toCSSParseException("invalidRule",e));

}

catch(TokenMgrErrore){

getErrorHandler().error(toCSSParseException(e));

}

catch(CSSParseExceptione){

getErrorHandler().error(e);

}

}

publicSelectorListparseSelectors(InputSourcesource)throwsIOException{

this.source_=source;

ReInit(getCharStream(source));

SelectorListsl=null;

try{

sl=parseSelectorsInternal();

}

catch(ParseExceptione){

getErrorHandler().error(toCSSParseException("invalidSelectorList",e));

}

catch(TokenMgrErrore){

getErrorHandler().error(toCSSParseException(e));

}

catch(CSSParseExceptione){

getErrorHandler().error(e);

}

returnsl;

}

publicLexicalUnitparsePropertyValue(InputSourcesource)throwsIOException{

this.source_=source;

ReInit(getCharStream(source));

LexicalUnitlu=null;

try{

lu=expr();

}

catch(ParseExceptione){

getErrorHandler().error(toCSSParseException("invalidExpr",e));

}

catch(TokenMgrErrore){

getErrorHandler().error(toCSSParseException(e));

}

catch(CSSParseExceptione){

getErrorHandler().error(e);

}

returnlu;

}

publicbooleanparsePriority(InputSourcesource)throwsIOException{

this.source_=source;

ReInit(getCharStream(source));

booleanb=false;

try{

b=prio();

}

catch(ParseExceptione){

getErrorHandler().error(toCSSParseException("invalidPrio",e));

}

catch(TokenMgrErrore){

getErrorHandler().error(toCSSParseException(e));

}

catch(CSSParseExceptione){

getErrorHandler().error(e);

}

returnb;

}

publicSACMediaListparseMedia(InputSourcesource)throwsIOException{

this.source_=source;

ReInit(getCharStream(source));

SACMediaListImplml=newSACMediaListImpl();

try{

mediaList(ml);

}

catch(ParseExceptione){

getErrorHandler().error(toCSSParseException("invalidMediaList",e));

}

catch(TokenMgrErrore){

getErrorHandler().error(toCSSParseException(e));

}

catch(CSSParseExceptione){

getErrorHandler().error(e);

}

returnml;

}

privateCharStreamgetCharStream(InputSourcesource)throwsIOException{

if(source.getCharacterStream()!

=null){

returnnewCssCharStream(source.getCharacterStream(),1,1);

}

if(source.getByteStream()!

=null)

{

Stringencoding=source.getEncoding();

InputStreamReaderreader;

InputStreamReaderreader;

if((encoding==null)||(encoding.length()<1)){

reader=newInputStreamReader(source.getByteStream(),Charset.defaultCharset());

}

else{

reader=newInputStreamReader(source.getByteStream(),encoding);

}

returnnewCssCharStream(reader,1,1);

}

if(

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 图表模板

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1