From 7bc226b58110fa26d9dbd3f0c78095d06909ffc3 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 7 Feb 2007 15:11:09 +0000 Subject: [PATCH] Formatting --- src/com/stevesoft/pat/AmpersandRule.java | 27 +- src/com/stevesoft/pat/Any.java | 57 +- src/com/stevesoft/pat/BackG.java | 50 +- src/com/stevesoft/pat/BackMatch.java | 66 +- src/com/stevesoft/pat/BackRefRule.java | 33 +- src/com/stevesoft/pat/Backup.java | 51 +- src/com/stevesoft/pat/BasicStringBufferLike.java | 12 +- src/com/stevesoft/pat/Bits.java | 5871 ++++++++++---------- src/com/stevesoft/pat/Boundary.java | 121 +- src/com/stevesoft/pat/Bracket.java | 103 +- src/com/stevesoft/pat/CaseMgr.java | 5862 ++++++++++++++----- src/com/stevesoft/pat/ChangeRule.java | 47 +- src/com/stevesoft/pat/CodeRule.java | 31 +- src/com/stevesoft/pat/Ctrl.java | 522 +- src/com/stevesoft/pat/Custom.java | 70 +- src/com/stevesoft/pat/CustomEndpoint.java | 46 +- src/com/stevesoft/pat/DirFileRegex.java | 24 +- src/com/stevesoft/pat/DotMulti.java | 286 +- src/com/stevesoft/pat/End.java | 78 +- src/com/stevesoft/pat/FastBracket.java | 379 +- src/com/stevesoft/pat/FastMulti.java | 238 +- src/com/stevesoft/pat/FileRegex.java | 396 +- src/com/stevesoft/pat/Group.java | 87 +- src/com/stevesoft/pat/LeftRule.java | 23 +- src/com/stevesoft/pat/Multi.java | 107 +- src/com/stevesoft/pat/MultiMin.java | 14 +- src/com/stevesoft/pat/Multi_stage2.java | 209 +- src/com/stevesoft/pat/NoPattern.java | 32 +- src/com/stevesoft/pat/NonDirFileRegex.java | 24 +- src/com/stevesoft/pat/NotImplementedError.java | 11 +- src/com/stevesoft/pat/NullPattern.java | 36 +- src/com/stevesoft/pat/NullRule.java | 21 +- src/com/stevesoft/pat/Or.java | 166 +- src/com/stevesoft/pat/OrMark.java | 92 +- src/com/stevesoft/pat/PartialBuffer.java | 55 +- src/com/stevesoft/pat/Pattern.java | 433 +- src/com/stevesoft/pat/PatternSub.java | 10 +- src/com/stevesoft/pat/PopRule.java | 17 +- src/com/stevesoft/pat/Prop.java | 85 +- src/com/stevesoft/pat/Pthings.java | 44 +- src/com/stevesoft/pat/PushRule.java | 41 +- src/com/stevesoft/pat/RBuffer.java | 39 +- src/com/stevesoft/pat/Range.java | 125 +- src/com/stevesoft/pat/RegOpt.java | 720 ++- src/com/stevesoft/pat/RegRes.java | 394 +- src/com/stevesoft/pat/RegSyntax.java | 19 +- src/com/stevesoft/pat/RegSyntaxError.java | 29 +- src/com/stevesoft/pat/Regex.java | 3260 ++++++----- src/com/stevesoft/pat/RegexReader.java | 281 +- src/com/stevesoft/pat/RegexTokenizer.java | 231 +- src/com/stevesoft/pat/RegexWriter.java | 334 +- src/com/stevesoft/pat/ReplaceRule.java | 571 +- src/com/stevesoft/pat/Replacer.java | 522 +- src/com/stevesoft/pat/RightRule.java | 25 +- src/com/stevesoft/pat/Rthings.java | 70 +- src/com/stevesoft/pat/RuleHolder.java | 42 +- src/com/stevesoft/pat/Skip.java | 263 +- src/com/stevesoft/pat/Skip2.java | 61 +- src/com/stevesoft/pat/SkipBMH.java | 390 +- src/com/stevesoft/pat/Skipped.java | 53 +- src/com/stevesoft/pat/SpecialRule.java | 11 +- src/com/stevesoft/pat/Start.java | 63 +- src/com/stevesoft/pat/StrPos.java | 245 +- src/com/stevesoft/pat/StringBufferLike.java | 102 +- src/com/stevesoft/pat/StringLike.java | 43 +- src/com/stevesoft/pat/StringRule.java | 33 +- src/com/stevesoft/pat/SubMark.java | 29 +- src/com/stevesoft/pat/TransPat.java | 54 +- src/com/stevesoft/pat/Transformer.java | 293 +- src/com/stevesoft/pat/UniValidator.java | 19 +- src/com/stevesoft/pat/Validator.java | 98 +- src/com/stevesoft/pat/WantMoreTextReplaceRule.java | 21 +- src/com/stevesoft/pat/lookAhead.java | 115 +- src/com/stevesoft/pat/oneChar.java | 95 +- src/com/stevesoft/pat/parsePerl.java | 591 +- src/com/stevesoft/pat/patInf.java | 9 +- src/com/stevesoft/pat/patInt.java | 213 +- .../stevesoft/pat/wrap/CharArrayBufferWrap.java | 39 +- src/com/stevesoft/pat/wrap/CharArrayWrap.java | 81 +- .../stevesoft/pat/wrap/RandomAccessFileWrap.java | 229 +- src/com/stevesoft/pat/wrap/StringBufferWrap.java | 25 +- src/com/stevesoft/pat/wrap/StringWrap.java | 62 +- src/com/stevesoft/pat/wrap/WriterWrap.java | 40 +- src/ext/vamsas/IRegistry.java | 7 +- src/ext/vamsas/IRegistryService.java | 12 +- src/ext/vamsas/IRegistryServiceLocator.java | 265 +- src/ext/vamsas/Jpred.java | 19 +- src/ext/vamsas/JpredService.java | 12 +- src/ext/vamsas/JpredServiceLocator.java | 264 +- src/ext/vamsas/JpredSoapBindingStub.java | 604 +- src/ext/vamsas/MuscleWS.java | 56 +- src/ext/vamsas/MuscleWSService.java | 48 +- src/ext/vamsas/MuscleWSServiceLocator.java | 316 +- src/ext/vamsas/MuscleWSSoapBindingStub.java | 788 +-- src/ext/vamsas/RegistryServiceSoapBindingStub.java | 352 +- src/ext/vamsas/ServiceHandle.java | 445 +- src/ext/vamsas/ServiceHandles.java | 239 +- src/jalview/analysis/AAFrequency.java | 220 +- src/jalview/analysis/AlignSeq.java | 1499 ++--- src/jalview/analysis/AlignmentSorter.java | 805 +-- src/jalview/analysis/Conservation.java | 884 +-- src/jalview/analysis/Finder.java | 531 +- src/jalview/analysis/NJTree.java | 2081 +++---- src/jalview/analysis/PCA.java | 402 +- src/jalview/analysis/SeqsetUtils.java | 128 +- src/jalview/analysis/SequenceIdMatcher.java | 86 +- src/jalview/appletgui/APopupMenu.java | 318 +- src/jalview/appletgui/AlignFrame.java | 1770 +++--- src/jalview/appletgui/AlignViewport.java | 420 +- src/jalview/appletgui/AlignmentPanel.java | 194 +- src/jalview/appletgui/AnnotationColourChooser.java | 94 +- src/jalview/appletgui/AnnotationLabels.java | 109 +- src/jalview/appletgui/AnnotationPanel.java | 717 +-- src/jalview/appletgui/CutAndPasteTransfer.java | 158 +- src/jalview/appletgui/EditNameDialog.java | 21 +- src/jalview/appletgui/FeatureRenderer.java | 601 +- src/jalview/appletgui/FeatureSettings.java | 435 +- src/jalview/appletgui/Finder.java | 144 +- src/jalview/appletgui/FontChooser.java | 126 +- src/jalview/appletgui/IdCanvas.java | 121 +- src/jalview/appletgui/IdPanel.java | 48 +- src/jalview/appletgui/IdwidthAdjuster.java | 2 +- src/jalview/appletgui/OverviewPanel.java | 145 +- src/jalview/appletgui/PCAPanel.java | 141 +- src/jalview/appletgui/PaintRefresher.java | 279 +- src/jalview/appletgui/PairwiseAlignPanel.java | 43 +- src/jalview/appletgui/RedundancyPanel.java | 268 +- src/jalview/appletgui/RotatableCanvas.java | 85 +- src/jalview/appletgui/ScalePanel.java | 126 +- src/jalview/appletgui/SeqCanvas.java | 837 +-- src/jalview/appletgui/SeqPanel.java | 1634 +++--- src/jalview/appletgui/SequenceRenderer.java | 75 +- src/jalview/appletgui/SliderPanel.java | 119 +- src/jalview/appletgui/Tooltip.java | 376 +- src/jalview/appletgui/TreeCanvas.java | 143 +- src/jalview/appletgui/TreePanel.java | 155 +- src/jalview/appletgui/UserDefinedColours.java | 256 +- src/jalview/bin/Cache.java | 474 +- src/jalview/bin/Jalview.java | 608 +- src/jalview/bin/JalviewLite.java | 860 +-- src/jalview/commands/ChangeCaseCommand.java | 23 +- src/jalview/commands/CommandI.java | 10 +- src/jalview/commands/EditCommand.java | 394 +- src/jalview/commands/OrderCommand.java | 80 +- src/jalview/commands/RemoveGapColCommand.java | 27 +- src/jalview/commands/RemoveGapsCommand.java | 46 +- src/jalview/commands/TrimRegionCommand.java | 67 +- src/jalview/datamodel/Alignment.java | 997 ++-- src/jalview/datamodel/AlignmentAnnotation.java | 533 +- src/jalview/datamodel/AlignmentI.java | 449 +- src/jalview/datamodel/AlignmentOrder.java | 451 +- src/jalview/datamodel/AlignmentView.java | 160 +- src/jalview/datamodel/Annotation.java | 117 +- src/jalview/datamodel/BinaryNode.java | 440 +- src/jalview/datamodel/BinarySequence.java | 283 +- src/jalview/datamodel/CigarArray.java | 168 +- src/jalview/datamodel/CigarBase.java | 228 +- src/jalview/datamodel/CigarCigar.java | 35 +- src/jalview/datamodel/CigarSimple.java | 14 +- src/jalview/datamodel/ColumnSelection.java | 413 +- src/jalview/datamodel/DBRefEntry.java | 14 +- src/jalview/datamodel/DBRefSource.java | 52 +- src/jalview/datamodel/GraphLine.java | 58 +- src/jalview/datamodel/HiddenSequences.java | 152 +- src/jalview/datamodel/PDBEntry.java | 30 +- src/jalview/datamodel/Provenance.java | 17 +- src/jalview/datamodel/ProvenanceEntry.java | 41 +- src/jalview/datamodel/SearchResults.java | 101 +- src/jalview/datamodel/SeqCigar.java | 152 +- src/jalview/datamodel/Sequence.java | 189 +- src/jalview/datamodel/SequenceFeature.java | 460 +- src/jalview/datamodel/SequenceGroup.java | 956 ++-- src/jalview/datamodel/SequenceI.java | 473 +- src/jalview/datamodel/SequenceNode.java | 234 +- src/jalview/datamodel/SequencePoint.java | 24 +- src/jalview/datamodel/UniprotEntry.java | 42 +- src/jalview/datamodel/UniprotFile.java | 19 +- src/jalview/datamodel/UniprotProteinName.java | 4 +- src/jalview/datamodel/UniprotSequence.java | 14 +- src/jalview/gui/AlignFrame.java | 1420 ++--- src/jalview/gui/AlignViewport.java | 2888 +++++----- src/jalview/gui/AlignmentPanel.java | 268 +- src/jalview/gui/AnnotationColourChooser.java | 96 +- src/jalview/gui/AnnotationExporter.java | 113 +- src/jalview/gui/AnnotationLabels.java | 1065 ++-- src/jalview/gui/AnnotationPanel.java | 2080 +++---- src/jalview/gui/CutAndPasteTransfer.java | 342 +- src/jalview/gui/DasSourceBrowser.java | 571 +- src/jalview/gui/Desktop.java | 1429 ++--- src/jalview/gui/EPSOptions.java | 17 +- src/jalview/gui/EditNameDialog.java | 20 +- src/jalview/gui/FeatureRenderer.java | 1139 ++-- src/jalview/gui/FeatureSettings.java | 835 +-- src/jalview/gui/Finder.java | 306 +- src/jalview/gui/FontChooser.java | 386 +- src/jalview/gui/IdCanvas.java | 712 +-- src/jalview/gui/IdPanel.java | 629 +-- src/jalview/gui/IdwidthAdjuster.java | 243 +- src/jalview/gui/Jalview2XML.java | 2735 ++++----- src/jalview/gui/Jalview2XML_V1.java | 757 +-- src/jalview/gui/OverviewPanel.java | 673 +-- src/jalview/gui/PCAPanel.java | 723 ++- src/jalview/gui/PaintRefresher.java | 293 +- src/jalview/gui/PairwiseAlignPanel.java | 218 +- src/jalview/gui/PopupMenu.java | 1897 +++---- src/jalview/gui/Preferences.java | 769 +-- src/jalview/gui/RedundancyPanel.java | 483 +- src/jalview/gui/RotatableCanvas.java | 1228 ++-- src/jalview/gui/ScalePanel.java | 683 +-- src/jalview/gui/SeqCanvas.java | 1472 ++--- src/jalview/gui/SeqPanel.java | 2429 ++++---- src/jalview/gui/SequenceFetcher.java | 308 +- src/jalview/gui/SequenceRenderer.java | 653 +-- src/jalview/gui/SliderPanel.java | 545 +- src/jalview/gui/SplashScreen.java | 251 +- src/jalview/gui/TextColourChooser.java | 55 +- src/jalview/gui/TreeCanvas.java | 34 +- src/jalview/gui/TreePanel.java | 1001 ++-- src/jalview/gui/UserDefinedColours.java | 1381 ++--- src/jalview/gui/UserQuestionnaireCheck.java | 223 +- src/jalview/gui/VamsasClient.java | 161 +- src/jalview/gui/WebserviceInfo.java | 776 +-- src/jalview/io/AMSAFile.java | 131 +- src/jalview/io/AlignFile.java | 290 +- src/jalview/io/AnnotationFile.java | 350 +- src/jalview/io/AppletFormatAdapter.java | 456 +- src/jalview/io/BLCFile.java | 324 +- src/jalview/io/ClustalFile.java | 12 +- src/jalview/io/DBRefFetcher.java | 119 +- src/jalview/io/DasSequenceFeatureFetcher.java | 352 +- src/jalview/io/EBIFetchClient.java | 415 +- src/jalview/io/FastaFile.java | 330 +- src/jalview/io/FeaturesFile.java | 878 +-- src/jalview/io/FileLoader.java | 238 +- src/jalview/io/FileParse.java | 4 +- src/jalview/io/FormatAdapter.java | 201 +- src/jalview/io/HTMLOutput.java | 224 +- src/jalview/io/IdentifyFile.java | 284 +- src/jalview/io/JPredFile.java | 598 +- src/jalview/io/JalviewFileChooser.java | 48 +- src/jalview/io/JalviewFileFilter.java | 4 +- src/jalview/io/JalviewFileView.java | 2 +- src/jalview/io/JnetAnnotationMaker.java | 97 +- src/jalview/io/MSFfile.java | 639 +-- src/jalview/io/ModellerDescription.java | 34 +- src/jalview/io/NewickFile.java | 1411 ++--- src/jalview/io/PIRFile.java | 138 +- src/jalview/io/PfamFile.java | 13 +- src/jalview/io/PileUpfile.java | 55 +- src/jalview/io/StockholmFile.java | 754 +-- src/jalview/io/VamsasDatastore.java | 998 ++-- src/jalview/io/WSWUBlastClient.java | 482 +- src/jalview/jbgui/GAlignFrame.java | 121 +- src/jalview/jbgui/GAlignmentPanel.java | 2 +- src/jalview/jbgui/GCutAndPasteTransfer.java | 289 +- src/jalview/jbgui/GDasSourceBrowser.java | 23 +- src/jalview/jbgui/GDesktop.java | 470 +- src/jalview/jbgui/GFinder.java | 31 +- src/jalview/jbgui/GFontChooser.java | 350 +- src/jalview/jbgui/GPCAPanel.java | 6 +- src/jalview/jbgui/GPairwiseAlignPanel.java | 136 +- src/jalview/jbgui/GPreferences.java | 430 +- src/jalview/jbgui/GSequenceLink.java | 57 +- src/jalview/jbgui/GSliderPanel.java | 296 +- src/jalview/jbgui/GTreePanel.java | 5 +- src/jalview/jbgui/GUserDefinedColours.java | 286 +- src/jalview/jbgui/GWebserviceInfo.java | 171 +- src/jalview/math/Matrix.java | 1473 +++-- src/jalview/math/RotatableMatrix.java | 469 +- src/jalview/schemabinding/version2/Annotation.java | 1214 ++-- .../schemabinding/version2/AnnotationColours.java | 732 +-- .../version2/AnnotationColoursDescriptor.java | 810 +-- .../version2/AnnotationDescriptor.java | 1133 ++-- .../schemabinding/version2/AnnotationElement.java | 680 +-- .../version2/AnnotationElementDescriptor.java | 821 +-- src/jalview/schemabinding/version2/Colour.java | 307 +- .../schemabinding/version2/ColourDescriptor.java | 451 +- src/jalview/schemabinding/version2/DBRef.java | 359 +- .../schemabinding/version2/DBRefDescriptor.java | 529 +- src/jalview/schemabinding/version2/Feature.java | 1049 ++-- .../schemabinding/version2/FeatureDescriptor.java | 959 ++-- .../schemabinding/version2/FeatureSettings.java | 466 +- .../version2/FeatureSettingsDescriptor.java | 385 +- src/jalview/schemabinding/version2/Features.java | 178 +- .../schemabinding/version2/FeaturesDescriptor.java | 295 +- .../schemabinding/version2/HiddenColumns.java | 415 +- .../version2/HiddenColumnsDescriptor.java | 476 +- src/jalview/schemabinding/version2/JGroup.java | 1787 +++--- .../schemabinding/version2/JGroupDescriptor.java | 1563 +++--- src/jalview/schemabinding/version2/JSeq.java | 1674 +++--- .../schemabinding/version2/JSeqDescriptor.java | 994 ++-- .../schemabinding/version2/JalviewModel.java | 418 +- .../version2/JalviewModelDescriptor.java | 630 ++- .../version2/JalviewModelSequence.java | 1818 +++--- .../version2/JalviewModelSequenceDescriptor.java | 761 +-- .../schemabinding/version2/JalviewUserColours.java | 542 +- .../version2/JalviewUserColoursDescriptor.java | 457 +- src/jalview/schemabinding/version2/OtherData.java | 307 +- .../version2/OtherDataDescriptor.java | 458 +- src/jalview/schemabinding/version2/Pdbentry.java | 670 +-- .../schemabinding/version2/PdbentryDescriptor.java | 606 +- .../schemabinding/version2/PdbentryItem.java | 358 +- .../version2/PdbentryItemDescriptor.java | 385 +- src/jalview/schemabinding/version2/Pdbids.java | 178 +- .../schemabinding/version2/PdbidsDescriptor.java | 295 +- src/jalview/schemabinding/version2/Property.java | 307 +- .../schemabinding/version2/PropertyDescriptor.java | 458 +- src/jalview/schemabinding/version2/Sequence.java | 464 +- .../schemabinding/version2/SequenceDescriptor.java | 392 +- .../schemabinding/version2/SequenceSet.java | 870 +-- .../version2/SequenceSetDescriptor.java | 538 +- .../schemabinding/version2/SequenceType.java | 411 +- .../version2/SequenceTypeDescriptor.java | 617 +- src/jalview/schemabinding/version2/Setting.java | 467 +- .../schemabinding/version2/SettingDescriptor.java | 563 +- .../schemabinding/version2/ThresholdLine.java | 467 +- .../version2/ThresholdLineDescriptor.java | 554 +- src/jalview/schemabinding/version2/Tree.java | 1635 +++--- .../schemabinding/version2/TreeDescriptor.java | 1652 +++--- .../schemabinding/version2/UserColourScheme.java | 178 +- .../version2/UserColourSchemeDescriptor.java | 295 +- .../schemabinding/version2/UserColours.java | 308 +- .../version2/UserColoursDescriptor.java | 459 +- src/jalview/schemabinding/version2/VAMSAS.java | 812 +-- .../schemabinding/version2/VAMSASDescriptor.java | 464 +- .../schemabinding/version2/VamsasModel.java | 178 +- .../version2/VamsasModelDescriptor.java | 295 +- src/jalview/schemabinding/version2/Viewport.java | 3497 ++++++------ .../schemabinding/version2/ViewportDescriptor.java | 3180 ++++++----- src/jalview/schemes/AnnotationColourGradient.java | 305 +- src/jalview/schemes/Blosum62ColourScheme.java | 20 +- src/jalview/schemes/BuriedColourScheme.java | 76 +- src/jalview/schemes/ClustalxColourScheme.java | 23 +- src/jalview/schemes/ColourSchemeI.java | 5 +- src/jalview/schemes/ColourSchemeProperty.java | 704 +-- src/jalview/schemes/Consensus.java | 2 +- src/jalview/schemes/HelixColourScheme.java | 2 +- src/jalview/schemes/HydrophobicColourScheme.java | 76 +- src/jalview/schemes/NucleotideColourScheme.java | 132 +- src/jalview/schemes/PIDColourScheme.java | 37 +- src/jalview/schemes/ResidueColourScheme.java | 426 +- src/jalview/schemes/ResidueProperties.java | 44 +- src/jalview/schemes/ScoreColourScheme.java | 198 +- src/jalview/schemes/ScoreMatrix.java | 41 +- src/jalview/schemes/StrandColourScheme.java | 76 +- src/jalview/schemes/TaylorColourScheme.java | 2 +- src/jalview/schemes/TurnColourScheme.java | 76 +- src/jalview/schemes/UserColourScheme.java | 97 +- src/jalview/schemes/ZappoColourScheme.java | 52 +- src/jalview/util/BrowserLauncher.java | 7 +- src/jalview/util/Comparison.java | 60 +- src/jalview/util/DBRefUtils.java | 85 +- src/jalview/util/Format.java | 1432 ++--- src/jalview/util/ImageMaker.java | 55 +- src/jalview/util/MapList.java | 443 +- src/jalview/util/QuickSort.java | 2 +- src/jalview/util/ShiftList.java | 74 +- src/jalview/util/TableSorter.java | 928 ++-- src/jalview/ws/Discoverer.java | 141 +- src/jalview/ws/JPredClient.java | 132 +- src/jalview/ws/JPredThread.java | 325 +- src/jalview/ws/MsaWSClient.java | 72 +- src/jalview/ws/MsaWSThread.java | 84 +- src/jalview/ws/WSClient.java | 12 +- src/jalview/ws/WSClientI.java | 22 +- src/jalview/ws/WSThread.java | 249 +- .../biojava/dasobert/das/DAS_FeatureRetrieve.java | 369 +- .../biojava/dasobert/das/DAS_Feature_Handler.java | 322 +- src/org/biojava/dasobert/das/FeatureThread.java | 282 +- src/org/biojava/dasobert/das2/Das2Capability.java | 47 +- .../biojava/dasobert/das2/Das2CapabilityImpl.java | 165 +- src/org/biojava/dasobert/das2/Das2Source.java | 28 +- src/org/biojava/dasobert/das2/Das2SourceImpl.java | 211 +- .../biojava/dasobert/das2/DasSourceConverter.java | 93 +- .../dasobert/das2/io/DAS2SourceHandler.java | 309 +- .../biojava/dasobert/das2/io/DasSourceReader.java | 11 +- .../dasobert/das2/io/DasSourceReaderImpl.java | 260 +- .../biojava/dasobert/dasregistry/Das1Source.java | 386 +- .../dasobert/dasregistry/Das2Validator.java | 31 +- .../dasregistry/DasCoordSysComparator.java | 156 +- .../dasobert/dasregistry/DasCoordinateSystem.java | 293 +- .../biojava/dasobert/dasregistry/DasSource.java | 104 +- .../dasobert/dasregistry/DasSourceComparator.java | 220 +- .../biojava/dasobert/eventmodel/FeatureEvent.java | 99 +- .../dasobert/eventmodel/FeatureListener.java | 38 +- .../dasobert/eventmodel/ObjectListener.java | 38 +- .../biojava/dasobert/eventmodel/SequenceEvent.java | 37 +- .../dasobert/eventmodel/SequenceListener.java | 51 +- src/org/jibble/epsgraphics/EpsDocument.java | 423 +- src/org/jibble/epsgraphics/EpsException.java | 37 +- src/org/jibble/epsgraphics/EpsGraphics2D.java | 2647 ++++----- src/uk/ac/ebi/www/Data.java | 215 +- src/uk/ac/ebi/www/InputParams.java | 805 +-- src/uk/ac/ebi/www/WSFile.java | 215 +- src/uk/ac/ebi/www/WSWUBlast.java | 32 +- src/uk/ac/ebi/www/WSWUBlastService.java | 12 +- src/uk/ac/ebi/www/WSWUBlastServiceLocator.java | 169 +- src/uk/ac/ebi/www/WSWUBlastSoapBindingStub.java | 773 ++- src/vamsas/IMsaWS.java | 57 +- src/vamsas/objects/simple/Alignment.java | 297 +- src/vamsas/objects/simple/Alignment_Helper.java | 141 +- src/vamsas/objects/simple/JpredResult.java | 179 +- src/vamsas/objects/simple/JpredResult_Helper.java | 95 +- src/vamsas/objects/simple/MsaResult.java | 169 +- src/vamsas/objects/simple/MsaResult_Helper.java | 117 +- src/vamsas/objects/simple/Msfalignment.java | 179 +- src/vamsas/objects/simple/Msfalignment_Helper.java | 95 +- src/vamsas/objects/simple/Object.java | 110 +- src/vamsas/objects/simple/Object_Helper.java | 104 +- src/vamsas/objects/simple/Result.java | 632 ++- src/vamsas/objects/simple/Result_Helper.java | 194 +- src/vamsas/objects/simple/Secstructpred.java | 126 +- .../objects/simple/Secstructpred_Helper.java | 84 +- src/vamsas/objects/simple/Sequence.java | 179 +- src/vamsas/objects/simple/SequenceSet.java | 182 +- src/vamsas/objects/simple/SequenceSet_Helper.java | 117 +- src/vamsas/objects/simple/Sequence_Helper.java | 95 +- src/vamsas/objects/simple/WsJobId.java | 212 +- src/vamsas/objects/simple/WsJobId_Helper.java | 129 +- 419 files changed, 90515 insertions(+), 77145 deletions(-) diff --git a/src/com/stevesoft/pat/AmpersandRule.java b/src/com/stevesoft/pat/AmpersandRule.java index 934d9c0..f838ab2 100755 --- a/src/com/stevesoft/pat/AmpersandRule.java +++ b/src/com/stevesoft/pat/AmpersandRule.java @@ -8,13 +8,22 @@ package com.stevesoft.pat; /** This implements the $& element of the second argument to - * Regex. - * @see com.stevesoft.pat.ReplaceRule - */ -public final class AmpersandRule extends ReplaceRule { - public AmpersandRule() {} - public void apply(StringBufferLike sb,RegRes res) { - sb.append(res.stringMatched()); - } - public String toString1() { return "$&"; } + * Regex. + * @see com.stevesoft.pat.ReplaceRule + */ +public final class AmpersandRule + extends ReplaceRule +{ + public AmpersandRule() + {} + + public void apply(StringBufferLike sb, RegRes res) + { + sb.append(res.stringMatched()); + } + + public String toString1() + { + return "$&"; + } } diff --git a/src/com/stevesoft/pat/Any.java b/src/com/stevesoft/pat/Any.java index 234c343..e833662 100755 --- a/src/com/stevesoft/pat/Any.java +++ b/src/com/stevesoft/pat/Any.java @@ -6,23 +6,50 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** This is the '.' character in a Pattern. It matches any character. */ -class Any extends Pattern { - public int matchInternal(int pos,Pthings pt) { - if(pos < pt.src.length()) - if(pt.dotDoesntMatchCR) { - if(pt.src.charAt(pos) != '\n') - return nextMatch(pos+1,pt); - } else return nextMatch(pos+1,pt); - return -1; - } - public String toString() { - return "."+nextString(); +class Any + extends Pattern +{ + public int matchInternal(int pos, Pthings pt) + { + if (pos < pt.src.length()) + { + if (pt.dotDoesntMatchCR) + { + if (pt.src.charAt(pos) != '\n') + { + return nextMatch(pos + 1, pt); + } + } + else + { + return nextMatch(pos + 1, pt); + } } - public patInt minChars() { return new patInt(1); } - public patInt maxChars() { return new patInt(1); } - public Pattern clone1(Hashtable h) { return new Any(); } + return -1; + } + + public String toString() + { + return "." + nextString(); + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + public Pattern clone1(Hashtable h) + { + return new Any(); + } }; diff --git a/src/com/stevesoft/pat/BackG.java b/src/com/stevesoft/pat/BackG.java index 78115f8..72c4c9a 100755 --- a/src/com/stevesoft/pat/BackG.java +++ b/src/com/stevesoft/pat/BackG.java @@ -6,21 +6,41 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** This class represents the \G pattern element. */ -class BackG extends Pattern { - char c,altc,altc2; - int mask; - public BackG() { - } - public int matchInternal(int pos,Pthings pt) { - return pos==pt.lastPos ? nextMatch(pos,pt) : -1; - } - public String toString() { - return "\\G"+nextString(); - } - public patInt minChars() { return new patInt(1); } - public patInt maxChars() { return new patInt(1); } - Pattern clone1(Hashtable h) { return new BackG(); } +class BackG + extends Pattern +{ + char c, altc, altc2; + int mask; + public BackG() + { + } + + public int matchInternal(int pos, Pthings pt) + { + return pos == pt.lastPos ? nextMatch(pos, pt) : -1; + } + + public String toString() + { + return "\\G" + nextString(); + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + Pattern clone1(Hashtable h) + { + return new BackG(); + } } diff --git a/src/com/stevesoft/pat/BackMatch.java b/src/com/stevesoft/pat/BackMatch.java index 168faec..2eed23b 100755 --- a/src/com/stevesoft/pat/BackMatch.java +++ b/src/com/stevesoft/pat/BackMatch.java @@ -6,28 +6,52 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** Provides the ability to match a backreference from within - * a Pattern. - */ -class BackMatch extends Pattern { - int id; - BackMatch(int id) { this.id = id; } - public String toString() { return "\\"+(id)+nextString(); } - public int matchInternal(int pos,Pthings p) { - int i1 = p.marks[id]; - int i2 = p.marks[id+p.nMarks]; - int imax = i2-i1; - if(i1<0||imax < 0||pos+imax>p.src.length()) return -1; - int ns = p.src.length()-pos; - if(imax < ns) ns = imax; - for(int i=0;i p.src.length()) + { + return -1; } - Pattern clone1(Hashtable h) { return new BackMatch(id); } -} + int ns = p.src.length() - pos; + if (imax < ns) + { + ns = imax; + } + for (int i = 0; i < ns; i++) + { + if (p.src.charAt(i + i1) != p.src.charAt(pos + i)) + { + return -1; + } + } + return nextMatch(pos + imax, p); + } + Pattern clone1(Hashtable h) + { + return new BackMatch(id); + } +} diff --git a/src/com/stevesoft/pat/BackRefRule.java b/src/com/stevesoft/pat/BackRefRule.java index 64a5d6e..8488ba3 100755 --- a/src/com/stevesoft/pat/BackRefRule.java +++ b/src/com/stevesoft/pat/BackRefRule.java @@ -11,13 +11,28 @@ package com.stevesoft.pat; a substitution rule. The apply(StringBufferLike sb,RegRes rr) method of this ReplaceRule simply appends the contents of rr.stringMatched(n), where n is the integer supplied to the constructor. */ -public class BackRefRule extends ReplaceRule { - int n; - public BackRefRule(int n) { this.n = n; } - public void apply(StringBufferLike sb,RegRes res) { - String x = res.stringMatched(n); - sb.append(x == null ? "" : x); - } - public String toString1() { return "$"+n; } - public Object clone1() { return new BackRefRule(n); } +public class BackRefRule + extends ReplaceRule +{ + int n; + public BackRefRule(int n) + { + this.n = n; + } + + public void apply(StringBufferLike sb, RegRes res) + { + String x = res.stringMatched(n); + sb.append(x == null ? "" : x); + } + + public String toString1() + { + return "$" + n; + } + + public Object clone1() + { + return new BackRefRule(n); + } } diff --git a/src/com/stevesoft/pat/Backup.java b/src/com/stevesoft/pat/Backup.java index df480ea..31c41c4 100755 --- a/src/com/stevesoft/pat/Backup.java +++ b/src/com/stevesoft/pat/Backup.java @@ -6,22 +6,47 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** Implements the (?<number) Pattern, where number is an integer telling us how far to back up in the Pattern. Not in perl 5. It also allows (?>number). */ -class Backup extends Pattern { - int bk; - Backup(int ii) { bk = ii; } - public String toString() { - return "(?" + (bk < 0 ? ">" + (-bk) : "<" + bk) + ")" + nextString(); - } - public int matchInternal(int pos,Pthings pt) { - if(pos < bk) return -1; - return nextMatch(pos-bk,pt); +class Backup + extends Pattern +{ + int bk; + Backup(int ii) + { + bk = ii; + } + + public String toString() + { + return "(?" + (bk < 0 ? ">" + ( -bk) : "<" + bk) + ")" + nextString(); + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos < bk) + { + return -1; } - public patInt minChars() { return new patInt(-bk); } - public patInt maxChars() { return new patInt(-bk); } - public Pattern clone1(Hashtable h) { return new Backup(bk); } + return nextMatch(pos - bk, pt); + } + + public patInt minChars() + { + return new patInt( -bk); + } + + public patInt maxChars() + { + return new patInt( -bk); + } + + public Pattern clone1(Hashtable h) + { + return new Backup(bk); + } }; diff --git a/src/com/stevesoft/pat/BasicStringBufferLike.java b/src/com/stevesoft/pat/BasicStringBufferLike.java index 6e7b26c..7563703 100755 --- a/src/com/stevesoft/pat/BasicStringBufferLike.java +++ b/src/com/stevesoft/pat/BasicStringBufferLike.java @@ -1,18 +1,22 @@ -package// +package // // This software is now distributed according to // the Lesser Gnu Public License. Please see // http://www.gnu.org/copyleft/lesser.txt for // the details. // -- Happy Computing! // -com.stevesoft.pat; + com.stevesoft.pat; /** An abstraction of the StringBuffer which only implements a subset of StringBuffer's methods. - */ -public interface BasicStringBufferLike { + */ +public interface BasicStringBufferLike +{ public void append(char c); + public void append(String s); + public StringLike toStringLike(); + public Object unwrap(); } diff --git a/src/com/stevesoft/pat/Bits.java b/src/com/stevesoft/pat/Bits.java index 0c67903..f26d1fb 100755 --- a/src/com/stevesoft/pat/Bits.java +++ b/src/com/stevesoft/pat/Bits.java @@ -1,40 +1,48 @@ -package// +package // // This software is now distributed according to // the Lesser Gnu Public License. Please see // http://www.gnu.org/copyleft/lesser.txt for // the details. // -- Happy Computing! // -com.stevesoft.pat; + com.stevesoft.pat; - -public class Bits { +public class Bits +{ char[] carray; - Bits(char[] carray) { + Bits(char[] carray) + { this.carray = carray; } - public boolean get(int i) { - return ((carray[i>>4]) & (1<<(i&15))) != 0; + + public boolean get(int i) + { + return ( (carray[i >> 4]) & (1 << (i & 15))) != 0; } - public void set(int i,boolean b) { - if(b) { - carray[i>>4] |= (char) 1<<(i&15); - } else { - carray[i>>4] &= (char)~(1<<(i&15)); + + public void set(int i, boolean b) + { + if (b) + { + carray[i >> 4] |= (char) 1 << (i & 15); + } + else + { + carray[i >> 4] &= (char)~ (1 << (i & 15)); } } /* - public static String n4(char c) { + public static String n4(char c) { String s = Integer.toHexString(c); while(s.length()<4) s = "0"+s; return s; - } - static abstract class Tester { + } + static abstract class Tester { abstract boolean test(char c); - } - public static void main(String[] args) throws Exception { + } + public static void main(String[] args) throws Exception { //pw_s.println(" static {"); FileWriter fw = new FileWriter("x.out"); fw.close(); @@ -80,30 +88,30 @@ public class Bits { }); test("punct",new Tester() { boolean test(char c) { - boolean r = false; + boolean r = false; switch(Character.getType(c)) { case Character.DASH_PUNCTUATION: case Character.START_PUNCTUATION: case Character.END_PUNCTUATION: case Character.CONNECTOR_PUNCTUATION: case Character.OTHER_PUNCTUATION: - r = true; - break; - default: - r = false; - break; - } - return r; + r = true; + break; + default: + r = false; + break; + } + return r; } }); //pw_s.println(" }"); fw = new FileWriter("x.out",true); fw.write(sw.toString()); fw.close(); - } - static StringWriter sw = new StringWriter(); - static PrintWriter pw_s = new PrintWriter(sw,true); - public static void test(String var,Tester t) throws Exception { + } + static StringWriter sw = new StringWriter(); + static PrintWriter pw_s = new PrintWriter(sw,true); + public static void test(String var,Tester t) throws Exception { char[] ca = new char[(66536 >> 4)+1]; Bits b = new Bits(ca); @@ -129,2943 +137,2960 @@ public class Bits { pw.println(" }"); pw.close(); - } - */ + } + */ public static Bits upper; - static void upper_f() { + static void upper_f() + { char[] data = new char[4159]; upper = new Bits(data); - data[4]=(char)0xfffe; - data[5]=(char)0x07ff; - data[12]=(char)0xffff; - data[13]=(char)0x7f7f; - data[16]=(char)0x5555; - data[17]=(char)0x5555; - data[18]=(char)0x5555; - data[19]=(char)0xaa55; - data[20]=(char)0x54aa; - data[21]=(char)0x5555; - data[22]=(char)0x5555; - data[23]=(char)0x2b55; - data[24]=(char)0xced6; - data[25]=(char)0xb1db; - data[26]=(char)0xd2d5; - data[27]=(char)0x11ae; - data[28]=(char)0xa490; - data[29]=(char)0x4aaa; - data[30]=(char)0x5555; - data[31]=(char)0x5412; - data[32]=(char)0x5555; - data[33]=(char)0x0055; - data[56]=(char)0xd740; - data[57]=(char)0xfffe; - data[58]=(char)0x0ffb; - data[61]=(char)0x541c; - data[62]=(char)0x5555; - data[64]=(char)0xdffe; - data[65]=(char)0xffff; - data[66]=(char)0xffff; - data[70]=(char)0x5555; - data[71]=(char)0x5555; - data[72]=(char)0x0001; - data[73]=(char)0x5555; - data[74]=(char)0x5555; - data[75]=(char)0x5555; - data[76]=(char)0x088a; - data[77]=(char)0x5555; - data[78]=(char)0x4555; - data[79]=(char)0x0115; - data[83]=(char)0xfffe; - data[84]=(char)0xffff; - data[85]=(char)0x007f; - data[266]=(char)0xffff; - data[267]=(char)0xffff; - data[268]=(char)0x003f; - data[480]=(char)0x5555; - data[481]=(char)0x5555; - data[482]=(char)0x5555; - data[483]=(char)0x5555; - data[484]=(char)0x5555; - data[485]=(char)0x5555; - data[486]=(char)0x5555; - data[487]=(char)0x5555; - data[488]=(char)0x5555; - data[489]=(char)0x0015; - data[490]=(char)0x5555; - data[491]=(char)0x5555; - data[492]=(char)0x5555; - data[493]=(char)0x5555; - data[494]=(char)0x5555; - data[495]=(char)0x0155; - data[496]=(char)0xff00; - data[497]=(char)0x3f00; - data[498]=(char)0xff00; - data[499]=(char)0xff00; - data[500]=(char)0x3f00; - data[501]=(char)0xaa00; - data[502]=(char)0xff00; - data[504]=(char)0xff00; - data[505]=(char)0xff00; - data[506]=(char)0xff00; - data[507]=(char)0x5f00; - data[508]=(char)0x1f00; - data[509]=(char)0x0f00; - data[510]=(char)0x1f00; - data[511]=(char)0x1f00; - data[528]=(char)0x3884; - data[529]=(char)0x3f27; - data[530]=(char)0x3d50; - data[531]=(char)0x000b; - data[4082]=(char)0xfffe; - data[4083]=(char)0x07ff; - data[4100]=(char)0xfffe; - data[4101]=(char)0x07ff; - data[4108]=(char)0xffff; - data[4109]=(char)0x7f7f; - data[4112]=(char)0x5555; - data[4113]=(char)0x5555; - data[4114]=(char)0x5555; - data[4115]=(char)0xaa55; - data[4116]=(char)0x54aa; - data[4117]=(char)0x5555; - data[4118]=(char)0x5555; - data[4119]=(char)0x2b55; - data[4120]=(char)0xced6; - data[4121]=(char)0xb1db; - data[4122]=(char)0xd2d5; - data[4123]=(char)0x11ae; - data[4124]=(char)0xa490; - data[4125]=(char)0x4aaa; - data[4126]=(char)0x5555; - data[4127]=(char)0x5412; - data[4128]=(char)0x5555; - data[4129]=(char)0x0055; - data[4152]=(char)0xd740; - data[4153]=(char)0xfffe; - data[4154]=(char)0x0ffb; - data[4157]=(char)0x541c; - data[4158]=(char)0x0055; + data[4] = (char) 0xfffe; + data[5] = (char) 0x07ff; + data[12] = (char) 0xffff; + data[13] = (char) 0x7f7f; + data[16] = (char) 0x5555; + data[17] = (char) 0x5555; + data[18] = (char) 0x5555; + data[19] = (char) 0xaa55; + data[20] = (char) 0x54aa; + data[21] = (char) 0x5555; + data[22] = (char) 0x5555; + data[23] = (char) 0x2b55; + data[24] = (char) 0xced6; + data[25] = (char) 0xb1db; + data[26] = (char) 0xd2d5; + data[27] = (char) 0x11ae; + data[28] = (char) 0xa490; + data[29] = (char) 0x4aaa; + data[30] = (char) 0x5555; + data[31] = (char) 0x5412; + data[32] = (char) 0x5555; + data[33] = (char) 0x0055; + data[56] = (char) 0xd740; + data[57] = (char) 0xfffe; + data[58] = (char) 0x0ffb; + data[61] = (char) 0x541c; + data[62] = (char) 0x5555; + data[64] = (char) 0xdffe; + data[65] = (char) 0xffff; + data[66] = (char) 0xffff; + data[70] = (char) 0x5555; + data[71] = (char) 0x5555; + data[72] = (char) 0x0001; + data[73] = (char) 0x5555; + data[74] = (char) 0x5555; + data[75] = (char) 0x5555; + data[76] = (char) 0x088a; + data[77] = (char) 0x5555; + data[78] = (char) 0x4555; + data[79] = (char) 0x0115; + data[83] = (char) 0xfffe; + data[84] = (char) 0xffff; + data[85] = (char) 0x007f; + data[266] = (char) 0xffff; + data[267] = (char) 0xffff; + data[268] = (char) 0x003f; + data[480] = (char) 0x5555; + data[481] = (char) 0x5555; + data[482] = (char) 0x5555; + data[483] = (char) 0x5555; + data[484] = (char) 0x5555; + data[485] = (char) 0x5555; + data[486] = (char) 0x5555; + data[487] = (char) 0x5555; + data[488] = (char) 0x5555; + data[489] = (char) 0x0015; + data[490] = (char) 0x5555; + data[491] = (char) 0x5555; + data[492] = (char) 0x5555; + data[493] = (char) 0x5555; + data[494] = (char) 0x5555; + data[495] = (char) 0x0155; + data[496] = (char) 0xff00; + data[497] = (char) 0x3f00; + data[498] = (char) 0xff00; + data[499] = (char) 0xff00; + data[500] = (char) 0x3f00; + data[501] = (char) 0xaa00; + data[502] = (char) 0xff00; + data[504] = (char) 0xff00; + data[505] = (char) 0xff00; + data[506] = (char) 0xff00; + data[507] = (char) 0x5f00; + data[508] = (char) 0x1f00; + data[509] = (char) 0x0f00; + data[510] = (char) 0x1f00; + data[511] = (char) 0x1f00; + data[528] = (char) 0x3884; + data[529] = (char) 0x3f27; + data[530] = (char) 0x3d50; + data[531] = (char) 0x000b; + data[4082] = (char) 0xfffe; + data[4083] = (char) 0x07ff; + data[4100] = (char) 0xfffe; + data[4101] = (char) 0x07ff; + data[4108] = (char) 0xffff; + data[4109] = (char) 0x7f7f; + data[4112] = (char) 0x5555; + data[4113] = (char) 0x5555; + data[4114] = (char) 0x5555; + data[4115] = (char) 0xaa55; + data[4116] = (char) 0x54aa; + data[4117] = (char) 0x5555; + data[4118] = (char) 0x5555; + data[4119] = (char) 0x2b55; + data[4120] = (char) 0xced6; + data[4121] = (char) 0xb1db; + data[4122] = (char) 0xd2d5; + data[4123] = (char) 0x11ae; + data[4124] = (char) 0xa490; + data[4125] = (char) 0x4aaa; + data[4126] = (char) 0x5555; + data[4127] = (char) 0x5412; + data[4128] = (char) 0x5555; + data[4129] = (char) 0x0055; + data[4152] = (char) 0xd740; + data[4153] = (char) 0xfffe; + data[4154] = (char) 0x0ffb; + data[4157] = (char) 0x541c; + data[4158] = (char) 0x0055; } + public static Bits lower; - static void lower_f() { + static void lower_f() + { char[] data = new char[4159]; lower = new Bits(data); - data[6]=(char)0xfffe; - data[7]=(char)0x07ff; - data[10]=(char)0x0400; - data[11]=(char)0x0420; - data[13]=(char)0x8000; - data[14]=(char)0xffff; - data[15]=(char)0xff7f; - data[16]=(char)0xaaaa; - data[17]=(char)0xaaaa; - data[18]=(char)0xaaaa; - data[19]=(char)0x55aa; - data[20]=(char)0xab55; - data[21]=(char)0xaaaa; - data[22]=(char)0xaaaa; - data[23]=(char)0xd4aa; - data[24]=(char)0x3129; - data[25]=(char)0x4e24; - data[26]=(char)0x292a; - data[27]=(char)0x2651; - data[28]=(char)0x5240; - data[29]=(char)0xb555; - data[30]=(char)0xaaaa; - data[31]=(char)0xa829; - data[32]=(char)0xaaaa; - data[33]=(char)0x00aa; - data[37]=(char)0xffff; - data[38]=(char)0xffff; - data[39]=(char)0xffff; - data[40]=(char)0xffff; - data[41]=(char)0xffff; - data[42]=(char)0x01ff; - data[57]=(char)0x0001; - data[58]=(char)0xf000; - data[59]=(char)0xffff; - data[60]=(char)0x7fff; - data[61]=(char)0x0063; - data[62]=(char)0xaaa8; - data[63]=(char)0x0007; - data[67]=(char)0xffff; - data[68]=(char)0xffff; - data[69]=(char)0xdffe; - data[70]=(char)0xaaaa; - data[71]=(char)0xaaaa; - data[72]=(char)0x0002; - data[73]=(char)0xaaaa; - data[74]=(char)0xaaaa; - data[75]=(char)0xaaaa; - data[76]=(char)0x1114; - data[77]=(char)0xaaaa; - data[78]=(char)0x8aaa; - data[79]=(char)0x022a; - data[86]=(char)0xfffe; - data[87]=(char)0xffff; - data[88]=(char)0x00ff; - data[269]=(char)0xffff; - data[270]=(char)0xffff; - data[271]=(char)0x007f; - data[480]=(char)0xaaaa; - data[481]=(char)0xaaaa; - data[482]=(char)0xaaaa; - data[483]=(char)0xaaaa; - data[484]=(char)0xaaaa; - data[485]=(char)0xaaaa; - data[486]=(char)0xaaaa; - data[487]=(char)0xaaaa; - data[488]=(char)0xaaaa; - data[489]=(char)0x0fea; - data[490]=(char)0xaaaa; - data[491]=(char)0xaaaa; - data[492]=(char)0xaaaa; - data[493]=(char)0xaaaa; - data[494]=(char)0xaaaa; - data[495]=(char)0x02aa; - data[496]=(char)0x00ff; - data[497]=(char)0x003f; - data[498]=(char)0x00ff; - data[499]=(char)0x00ff; - data[500]=(char)0x003f; - data[501]=(char)0x00ff; - data[502]=(char)0x00ff; - data[503]=(char)0x3fff; - data[504]=(char)0x00ff; - data[505]=(char)0x00ff; - data[506]=(char)0x00ff; - data[507]=(char)0x00df; - data[508]=(char)0x00dc; - data[509]=(char)0x00cf; - data[510]=(char)0x00ff; - data[511]=(char)0x00dc; - data[519]=(char)0x8000; - data[528]=(char)0xc400; - data[529]=(char)0x0008; - data[530]=(char)0xc000; - data[531]=(char)0x0010; - data[4016]=(char)0x007f; - data[4017]=(char)0x00f8; - data[4084]=(char)0xfffe; - data[4085]=(char)0x07ff; - data[4102]=(char)0xfffe; - data[4103]=(char)0x07ff; - data[4106]=(char)0x0400; - data[4107]=(char)0x0420; - data[4109]=(char)0x8000; - data[4110]=(char)0xffff; - data[4111]=(char)0xff7f; - data[4112]=(char)0xaaaa; - data[4113]=(char)0xaaaa; - data[4114]=(char)0xaaaa; - data[4115]=(char)0x55aa; - data[4116]=(char)0xab55; - data[4117]=(char)0xaaaa; - data[4118]=(char)0xaaaa; - data[4119]=(char)0xd4aa; - data[4120]=(char)0x3129; - data[4121]=(char)0x4e24; - data[4122]=(char)0x292a; - data[4123]=(char)0x2651; - data[4124]=(char)0x5240; - data[4125]=(char)0xb555; - data[4126]=(char)0xaaaa; - data[4127]=(char)0xa829; - data[4128]=(char)0xaaaa; - data[4129]=(char)0x00aa; - data[4133]=(char)0xffff; - data[4134]=(char)0xffff; - data[4135]=(char)0xffff; - data[4136]=(char)0xffff; - data[4137]=(char)0xffff; - data[4138]=(char)0x01ff; - data[4153]=(char)0x0001; - data[4154]=(char)0xf000; - data[4155]=(char)0xffff; - data[4156]=(char)0x7fff; - data[4157]=(char)0x0063; - data[4158]=(char)0x00a8; + data[6] = (char) 0xfffe; + data[7] = (char) 0x07ff; + data[10] = (char) 0x0400; + data[11] = (char) 0x0420; + data[13] = (char) 0x8000; + data[14] = (char) 0xffff; + data[15] = (char) 0xff7f; + data[16] = (char) 0xaaaa; + data[17] = (char) 0xaaaa; + data[18] = (char) 0xaaaa; + data[19] = (char) 0x55aa; + data[20] = (char) 0xab55; + data[21] = (char) 0xaaaa; + data[22] = (char) 0xaaaa; + data[23] = (char) 0xd4aa; + data[24] = (char) 0x3129; + data[25] = (char) 0x4e24; + data[26] = (char) 0x292a; + data[27] = (char) 0x2651; + data[28] = (char) 0x5240; + data[29] = (char) 0xb555; + data[30] = (char) 0xaaaa; + data[31] = (char) 0xa829; + data[32] = (char) 0xaaaa; + data[33] = (char) 0x00aa; + data[37] = (char) 0xffff; + data[38] = (char) 0xffff; + data[39] = (char) 0xffff; + data[40] = (char) 0xffff; + data[41] = (char) 0xffff; + data[42] = (char) 0x01ff; + data[57] = (char) 0x0001; + data[58] = (char) 0xf000; + data[59] = (char) 0xffff; + data[60] = (char) 0x7fff; + data[61] = (char) 0x0063; + data[62] = (char) 0xaaa8; + data[63] = (char) 0x0007; + data[67] = (char) 0xffff; + data[68] = (char) 0xffff; + data[69] = (char) 0xdffe; + data[70] = (char) 0xaaaa; + data[71] = (char) 0xaaaa; + data[72] = (char) 0x0002; + data[73] = (char) 0xaaaa; + data[74] = (char) 0xaaaa; + data[75] = (char) 0xaaaa; + data[76] = (char) 0x1114; + data[77] = (char) 0xaaaa; + data[78] = (char) 0x8aaa; + data[79] = (char) 0x022a; + data[86] = (char) 0xfffe; + data[87] = (char) 0xffff; + data[88] = (char) 0x00ff; + data[269] = (char) 0xffff; + data[270] = (char) 0xffff; + data[271] = (char) 0x007f; + data[480] = (char) 0xaaaa; + data[481] = (char) 0xaaaa; + data[482] = (char) 0xaaaa; + data[483] = (char) 0xaaaa; + data[484] = (char) 0xaaaa; + data[485] = (char) 0xaaaa; + data[486] = (char) 0xaaaa; + data[487] = (char) 0xaaaa; + data[488] = (char) 0xaaaa; + data[489] = (char) 0x0fea; + data[490] = (char) 0xaaaa; + data[491] = (char) 0xaaaa; + data[492] = (char) 0xaaaa; + data[493] = (char) 0xaaaa; + data[494] = (char) 0xaaaa; + data[495] = (char) 0x02aa; + data[496] = (char) 0x00ff; + data[497] = (char) 0x003f; + data[498] = (char) 0x00ff; + data[499] = (char) 0x00ff; + data[500] = (char) 0x003f; + data[501] = (char) 0x00ff; + data[502] = (char) 0x00ff; + data[503] = (char) 0x3fff; + data[504] = (char) 0x00ff; + data[505] = (char) 0x00ff; + data[506] = (char) 0x00ff; + data[507] = (char) 0x00df; + data[508] = (char) 0x00dc; + data[509] = (char) 0x00cf; + data[510] = (char) 0x00ff; + data[511] = (char) 0x00dc; + data[519] = (char) 0x8000; + data[528] = (char) 0xc400; + data[529] = (char) 0x0008; + data[530] = (char) 0xc000; + data[531] = (char) 0x0010; + data[4016] = (char) 0x007f; + data[4017] = (char) 0x00f8; + data[4084] = (char) 0xfffe; + data[4085] = (char) 0x07ff; + data[4102] = (char) 0xfffe; + data[4103] = (char) 0x07ff; + data[4106] = (char) 0x0400; + data[4107] = (char) 0x0420; + data[4109] = (char) 0x8000; + data[4110] = (char) 0xffff; + data[4111] = (char) 0xff7f; + data[4112] = (char) 0xaaaa; + data[4113] = (char) 0xaaaa; + data[4114] = (char) 0xaaaa; + data[4115] = (char) 0x55aa; + data[4116] = (char) 0xab55; + data[4117] = (char) 0xaaaa; + data[4118] = (char) 0xaaaa; + data[4119] = (char) 0xd4aa; + data[4120] = (char) 0x3129; + data[4121] = (char) 0x4e24; + data[4122] = (char) 0x292a; + data[4123] = (char) 0x2651; + data[4124] = (char) 0x5240; + data[4125] = (char) 0xb555; + data[4126] = (char) 0xaaaa; + data[4127] = (char) 0xa829; + data[4128] = (char) 0xaaaa; + data[4129] = (char) 0x00aa; + data[4133] = (char) 0xffff; + data[4134] = (char) 0xffff; + data[4135] = (char) 0xffff; + data[4136] = (char) 0xffff; + data[4137] = (char) 0xffff; + data[4138] = (char) 0x01ff; + data[4153] = (char) 0x0001; + data[4154] = (char) 0xf000; + data[4155] = (char) 0xffff; + data[4156] = (char) 0x7fff; + data[4157] = (char) 0x0063; + data[4158] = (char) 0x00a8; } + public static Bits title; - static void title_f() { + static void title_f() + { char[] data = new char[4159]; title = new Bits(data); - data[6]=(char)0xfffe; - data[7]=(char)0x07ff; - data[10]=(char)0x0400; - data[11]=(char)0x0420; - data[13]=(char)0x8000; - data[14]=(char)0xffff; - data[15]=(char)0xff7f; - data[16]=(char)0xaaaa; - data[17]=(char)0xaaaa; - data[18]=(char)0xaaaa; - data[19]=(char)0x55aa; - data[20]=(char)0xab55; - data[21]=(char)0xaaaa; - data[22]=(char)0xaaaa; - data[23]=(char)0xd4aa; - data[24]=(char)0x3129; - data[25]=(char)0x4e24; - data[26]=(char)0x292a; - data[27]=(char)0x2651; - data[28]=(char)0x5240; - data[29]=(char)0xb555; - data[30]=(char)0xaaaa; - data[31]=(char)0xa829; - data[32]=(char)0xaaaa; - data[33]=(char)0x00aa; - data[37]=(char)0xffff; - data[38]=(char)0xffff; - data[39]=(char)0xffff; - data[40]=(char)0xffff; - data[41]=(char)0xffff; - data[42]=(char)0x01ff; - data[57]=(char)0x0001; - data[58]=(char)0xf000; - data[59]=(char)0xffff; - data[60]=(char)0x7fff; - data[61]=(char)0x0063; - data[62]=(char)0xaaa8; - data[63]=(char)0x0007; - data[67]=(char)0xffff; - data[68]=(char)0xffff; - data[69]=(char)0xdffe; - data[70]=(char)0xaaaa; - data[71]=(char)0xaaaa; - data[72]=(char)0x0002; - data[73]=(char)0xaaaa; - data[74]=(char)0xaaaa; - data[75]=(char)0xaaaa; - data[76]=(char)0x1114; - data[77]=(char)0xaaaa; - data[78]=(char)0x8aaa; - data[79]=(char)0x022a; - data[86]=(char)0xfffe; - data[87]=(char)0xffff; - data[88]=(char)0x00ff; - data[269]=(char)0xffff; - data[270]=(char)0xffff; - data[271]=(char)0x007f; - data[480]=(char)0xaaaa; - data[481]=(char)0xaaaa; - data[482]=(char)0xaaaa; - data[483]=(char)0xaaaa; - data[484]=(char)0xaaaa; - data[485]=(char)0xaaaa; - data[486]=(char)0xaaaa; - data[487]=(char)0xaaaa; - data[488]=(char)0xaaaa; - data[489]=(char)0x0fea; - data[490]=(char)0xaaaa; - data[491]=(char)0xaaaa; - data[492]=(char)0xaaaa; - data[493]=(char)0xaaaa; - data[494]=(char)0xaaaa; - data[495]=(char)0x02aa; - data[496]=(char)0x00ff; - data[497]=(char)0x003f; - data[498]=(char)0x00ff; - data[499]=(char)0x00ff; - data[500]=(char)0x003f; - data[501]=(char)0x00ff; - data[502]=(char)0x00ff; - data[503]=(char)0x3fff; - data[504]=(char)0x00ff; - data[505]=(char)0x00ff; - data[506]=(char)0x00ff; - data[507]=(char)0x00df; - data[508]=(char)0x00dc; - data[509]=(char)0x00cf; - data[510]=(char)0x00ff; - data[511]=(char)0x00dc; - data[519]=(char)0x8000; - data[528]=(char)0xc400; - data[529]=(char)0x0008; - data[530]=(char)0xc000; - data[531]=(char)0x0010; - data[4016]=(char)0x007f; - data[4017]=(char)0x00f8; - data[4084]=(char)0xfffe; - data[4085]=(char)0x07ff; - data[4102]=(char)0xfffe; - data[4103]=(char)0x07ff; - data[4106]=(char)0x0400; - data[4107]=(char)0x0420; - data[4109]=(char)0x8000; - data[4110]=(char)0xffff; - data[4111]=(char)0xff7f; - data[4112]=(char)0xaaaa; - data[4113]=(char)0xaaaa; - data[4114]=(char)0xaaaa; - data[4115]=(char)0x55aa; - data[4116]=(char)0xab55; - data[4117]=(char)0xaaaa; - data[4118]=(char)0xaaaa; - data[4119]=(char)0xd4aa; - data[4120]=(char)0x3129; - data[4121]=(char)0x4e24; - data[4122]=(char)0x292a; - data[4123]=(char)0x2651; - data[4124]=(char)0x5240; - data[4125]=(char)0xb555; - data[4126]=(char)0xaaaa; - data[4127]=(char)0xa829; - data[4128]=(char)0xaaaa; - data[4129]=(char)0x00aa; - data[4133]=(char)0xffff; - data[4134]=(char)0xffff; - data[4135]=(char)0xffff; - data[4136]=(char)0xffff; - data[4137]=(char)0xffff; - data[4138]=(char)0x01ff; - data[4153]=(char)0x0001; - data[4154]=(char)0xf000; - data[4155]=(char)0xffff; - data[4156]=(char)0x7fff; - data[4157]=(char)0x0063; - data[4158]=(char)0x00a8; + data[6] = (char) 0xfffe; + data[7] = (char) 0x07ff; + data[10] = (char) 0x0400; + data[11] = (char) 0x0420; + data[13] = (char) 0x8000; + data[14] = (char) 0xffff; + data[15] = (char) 0xff7f; + data[16] = (char) 0xaaaa; + data[17] = (char) 0xaaaa; + data[18] = (char) 0xaaaa; + data[19] = (char) 0x55aa; + data[20] = (char) 0xab55; + data[21] = (char) 0xaaaa; + data[22] = (char) 0xaaaa; + data[23] = (char) 0xd4aa; + data[24] = (char) 0x3129; + data[25] = (char) 0x4e24; + data[26] = (char) 0x292a; + data[27] = (char) 0x2651; + data[28] = (char) 0x5240; + data[29] = (char) 0xb555; + data[30] = (char) 0xaaaa; + data[31] = (char) 0xa829; + data[32] = (char) 0xaaaa; + data[33] = (char) 0x00aa; + data[37] = (char) 0xffff; + data[38] = (char) 0xffff; + data[39] = (char) 0xffff; + data[40] = (char) 0xffff; + data[41] = (char) 0xffff; + data[42] = (char) 0x01ff; + data[57] = (char) 0x0001; + data[58] = (char) 0xf000; + data[59] = (char) 0xffff; + data[60] = (char) 0x7fff; + data[61] = (char) 0x0063; + data[62] = (char) 0xaaa8; + data[63] = (char) 0x0007; + data[67] = (char) 0xffff; + data[68] = (char) 0xffff; + data[69] = (char) 0xdffe; + data[70] = (char) 0xaaaa; + data[71] = (char) 0xaaaa; + data[72] = (char) 0x0002; + data[73] = (char) 0xaaaa; + data[74] = (char) 0xaaaa; + data[75] = (char) 0xaaaa; + data[76] = (char) 0x1114; + data[77] = (char) 0xaaaa; + data[78] = (char) 0x8aaa; + data[79] = (char) 0x022a; + data[86] = (char) 0xfffe; + data[87] = (char) 0xffff; + data[88] = (char) 0x00ff; + data[269] = (char) 0xffff; + data[270] = (char) 0xffff; + data[271] = (char) 0x007f; + data[480] = (char) 0xaaaa; + data[481] = (char) 0xaaaa; + data[482] = (char) 0xaaaa; + data[483] = (char) 0xaaaa; + data[484] = (char) 0xaaaa; + data[485] = (char) 0xaaaa; + data[486] = (char) 0xaaaa; + data[487] = (char) 0xaaaa; + data[488] = (char) 0xaaaa; + data[489] = (char) 0x0fea; + data[490] = (char) 0xaaaa; + data[491] = (char) 0xaaaa; + data[492] = (char) 0xaaaa; + data[493] = (char) 0xaaaa; + data[494] = (char) 0xaaaa; + data[495] = (char) 0x02aa; + data[496] = (char) 0x00ff; + data[497] = (char) 0x003f; + data[498] = (char) 0x00ff; + data[499] = (char) 0x00ff; + data[500] = (char) 0x003f; + data[501] = (char) 0x00ff; + data[502] = (char) 0x00ff; + data[503] = (char) 0x3fff; + data[504] = (char) 0x00ff; + data[505] = (char) 0x00ff; + data[506] = (char) 0x00ff; + data[507] = (char) 0x00df; + data[508] = (char) 0x00dc; + data[509] = (char) 0x00cf; + data[510] = (char) 0x00ff; + data[511] = (char) 0x00dc; + data[519] = (char) 0x8000; + data[528] = (char) 0xc400; + data[529] = (char) 0x0008; + data[530] = (char) 0xc000; + data[531] = (char) 0x0010; + data[4016] = (char) 0x007f; + data[4017] = (char) 0x00f8; + data[4084] = (char) 0xfffe; + data[4085] = (char) 0x07ff; + data[4102] = (char) 0xfffe; + data[4103] = (char) 0x07ff; + data[4106] = (char) 0x0400; + data[4107] = (char) 0x0420; + data[4109] = (char) 0x8000; + data[4110] = (char) 0xffff; + data[4111] = (char) 0xff7f; + data[4112] = (char) 0xaaaa; + data[4113] = (char) 0xaaaa; + data[4114] = (char) 0xaaaa; + data[4115] = (char) 0x55aa; + data[4116] = (char) 0xab55; + data[4117] = (char) 0xaaaa; + data[4118] = (char) 0xaaaa; + data[4119] = (char) 0xd4aa; + data[4120] = (char) 0x3129; + data[4121] = (char) 0x4e24; + data[4122] = (char) 0x292a; + data[4123] = (char) 0x2651; + data[4124] = (char) 0x5240; + data[4125] = (char) 0xb555; + data[4126] = (char) 0xaaaa; + data[4127] = (char) 0xa829; + data[4128] = (char) 0xaaaa; + data[4129] = (char) 0x00aa; + data[4133] = (char) 0xffff; + data[4134] = (char) 0xffff; + data[4135] = (char) 0xffff; + data[4136] = (char) 0xffff; + data[4137] = (char) 0xffff; + data[4138] = (char) 0x01ff; + data[4153] = (char) 0x0001; + data[4154] = (char) 0xf000; + data[4155] = (char) 0xffff; + data[4156] = (char) 0x7fff; + data[4157] = (char) 0x0063; + data[4158] = (char) 0x00a8; } + public static Bits currency; - static void currency_f() { + static void currency_f() + { char[] data = new char[4159]; currency = new Bits(data); - data[2]=(char)0x0010; - data[10]=(char)0x003c; - data[159]=(char)0x000c; - data[227]=(char)0x8000; - data[522]=(char)0x1fff; - data[4070]=(char)0x0200; - data[4080]=(char)0x0010; - data[4094]=(char)0x0063; - data[4098]=(char)0x0010; - data[4106]=(char)0x003c; + data[2] = (char) 0x0010; + data[10] = (char) 0x003c; + data[159] = (char) 0x000c; + data[227] = (char) 0x8000; + data[522] = (char) 0x1fff; + data[4070] = (char) 0x0200; + data[4080] = (char) 0x0010; + data[4094] = (char) 0x0063; + data[4098] = (char) 0x0010; + data[4106] = (char) 0x003c; } + public static Bits decimal_digit; - static void decimal_digit_f() { + static void decimal_digit_f() + { char[] data = new char[4159]; decimal_digit = new Bits(data); - data[3]=(char)0x03ff; - data[102]=(char)0x03ff; - data[111]=(char)0x03ff; - data[150]=(char)0xffc0; - data[158]=(char)0xffc0; - data[166]=(char)0xffc0; - data[174]=(char)0xffc0; - data[182]=(char)0xffc0; - data[190]=(char)0xff80; - data[198]=(char)0xffc0; - data[206]=(char)0xffc0; - data[214]=(char)0xffc0; - data[229]=(char)0x03ff; - data[237]=(char)0x03ff; - data[242]=(char)0x03ff; - data[4081]=(char)0x03ff; - data[4099]=(char)0x03ff; + data[3] = (char) 0x03ff; + data[102] = (char) 0x03ff; + data[111] = (char) 0x03ff; + data[150] = (char) 0xffc0; + data[158] = (char) 0xffc0; + data[166] = (char) 0xffc0; + data[174] = (char) 0xffc0; + data[182] = (char) 0xffc0; + data[190] = (char) 0xff80; + data[198] = (char) 0xffc0; + data[206] = (char) 0xffc0; + data[214] = (char) 0xffc0; + data[229] = (char) 0x03ff; + data[237] = (char) 0x03ff; + data[242] = (char) 0x03ff; + data[4081] = (char) 0x03ff; + data[4099] = (char) 0x03ff; } + public static Bits math; - static void math_f() { + static void math_f() + { char[] data = new char[4159]; math = new Bits(data); - data[2]=(char)0x0800; - data[3]=(char)0x7000; - data[7]=(char)0x5000; - data[10]=(char)0x1000; - data[11]=(char)0x0002; - data[13]=(char)0x0080; - data[15]=(char)0x0080; - data[516]=(char)0x0010; - data[519]=(char)0x1c00; - data[520]=(char)0x1c00; - data[537]=(char)0x001f; - data[541]=(char)0x0014; - data[544]=(char)0xffff; - data[545]=(char)0xffff; - data[546]=(char)0xffff; - data[547]=(char)0xffff; - data[548]=(char)0xffff; - data[549]=(char)0xffff; - data[550]=(char)0xffff; - data[551]=(char)0xffff; - data[552]=(char)0xffff; - data[553]=(char)0xffff; - data[554]=(char)0xffff; - data[555]=(char)0xffff; - data[556]=(char)0xffff; - data[557]=(char)0xffff; - data[558]=(char)0xffff; - data[559]=(char)0x0003; - data[560]=(char)0x0f00; - data[562]=(char)0x0003; - data[4018]=(char)0x0200; - data[4070]=(char)0x0074; - data[4080]=(char)0x0800; - data[4081]=(char)0x7000; - data[4085]=(char)0x5000; - data[4094]=(char)0x1f04; - data[4098]=(char)0x0800; - data[4099]=(char)0x7000; - data[4103]=(char)0x5000; - data[4106]=(char)0x1000; - data[4107]=(char)0x0002; - data[4109]=(char)0x0080; - data[4111]=(char)0x0080; + data[2] = (char) 0x0800; + data[3] = (char) 0x7000; + data[7] = (char) 0x5000; + data[10] = (char) 0x1000; + data[11] = (char) 0x0002; + data[13] = (char) 0x0080; + data[15] = (char) 0x0080; + data[516] = (char) 0x0010; + data[519] = (char) 0x1c00; + data[520] = (char) 0x1c00; + data[537] = (char) 0x001f; + data[541] = (char) 0x0014; + data[544] = (char) 0xffff; + data[545] = (char) 0xffff; + data[546] = (char) 0xffff; + data[547] = (char) 0xffff; + data[548] = (char) 0xffff; + data[549] = (char) 0xffff; + data[550] = (char) 0xffff; + data[551] = (char) 0xffff; + data[552] = (char) 0xffff; + data[553] = (char) 0xffff; + data[554] = (char) 0xffff; + data[555] = (char) 0xffff; + data[556] = (char) 0xffff; + data[557] = (char) 0xffff; + data[558] = (char) 0xffff; + data[559] = (char) 0x0003; + data[560] = (char) 0x0f00; + data[562] = (char) 0x0003; + data[4018] = (char) 0x0200; + data[4070] = (char) 0x0074; + data[4080] = (char) 0x0800; + data[4081] = (char) 0x7000; + data[4085] = (char) 0x5000; + data[4094] = (char) 0x1f04; + data[4098] = (char) 0x0800; + data[4099] = (char) 0x7000; + data[4103] = (char) 0x5000; + data[4106] = (char) 0x1000; + data[4107] = (char) 0x0002; + data[4109] = (char) 0x0080; + data[4111] = (char) 0x0080; } + public static Bits letter; - static void letter_f() { + static void letter_f() + { char[] data = new char[4159]; letter = new Bits(data); - data[4]=(char)0xfffe; - data[5]=(char)0x07ff; - data[6]=(char)0xfffe; - data[7]=(char)0x07ff; - data[10]=(char)0x0400; - data[11]=(char)0x0420; - data[12]=(char)0xffff; - data[13]=(char)0xff7f; - data[14]=(char)0xffff; - data[15]=(char)0xff7f; - data[16]=(char)0xffff; - data[17]=(char)0xffff; - data[18]=(char)0xffff; - data[19]=(char)0xffff; - data[20]=(char)0xffff; - data[21]=(char)0xffff; - data[22]=(char)0xffff; - data[23]=(char)0xffff; - data[24]=(char)0xffff; - data[25]=(char)0xffff; - data[26]=(char)0xffff; - data[27]=(char)0xffff; - data[28]=(char)0xffff; - data[29]=(char)0xffff; - data[30]=(char)0xffff; - data[31]=(char)0xfc3f; - data[32]=(char)0xffff; - data[33]=(char)0x00ff; - data[37]=(char)0xffff; - data[38]=(char)0xffff; - data[39]=(char)0xffff; - data[40]=(char)0xffff; - data[41]=(char)0xffff; - data[42]=(char)0x01ff; - data[43]=(char)0xf9ff; - data[44]=(char)0x0003; - data[45]=(char)0x0003; - data[46]=(char)0x001f; - data[55]=(char)0x0400; - data[56]=(char)0xd740; - data[57]=(char)0xffff; - data[58]=(char)0xfffb; - data[59]=(char)0xffff; - data[60]=(char)0x7fff; - data[61]=(char)0x547f; - data[62]=(char)0xfffd; - data[63]=(char)0x000f; - data[64]=(char)0xdffe; - data[65]=(char)0xffff; - data[66]=(char)0xffff; - data[67]=(char)0xffff; - data[68]=(char)0xffff; - data[69]=(char)0xdffe; - data[70]=(char)0xffff; - data[71]=(char)0xffff; - data[72]=(char)0x0003; - data[73]=(char)0xffff; - data[74]=(char)0xffff; - data[75]=(char)0xffff; - data[76]=(char)0x199f; - data[77]=(char)0xffff; - data[78]=(char)0xcfff; - data[79]=(char)0x033f; - data[83]=(char)0xfffe; - data[84]=(char)0xffff; - data[85]=(char)0x027f; - data[86]=(char)0xfffe; - data[87]=(char)0xffff; - data[88]=(char)0x00ff; - data[93]=(char)0xffff; - data[94]=(char)0x07ff; - data[95]=(char)0x0007; - data[98]=(char)0xfffe; - data[99]=(char)0x07ff; - data[100]=(char)0x07ff; - data[103]=(char)0xfffe; - data[104]=(char)0xffff; - data[105]=(char)0xffff; - data[106]=(char)0xffff; - data[107]=(char)0x7cff; - data[108]=(char)0x7fff; - data[109]=(char)0x002f; - data[110]=(char)0x0060; - data[144]=(char)0xffe0; - data[145]=(char)0xffff; - data[146]=(char)0xffff; - data[147]=(char)0x23ff; - data[149]=(char)0xff00; - data[150]=(char)0x0003; - data[152]=(char)0x9fe0; - data[153]=(char)0xfff9; - data[154]=(char)0xfdff; - data[155]=(char)0x03c5; - data[157]=(char)0xb000; - data[158]=(char)0x0003; - data[159]=(char)0x0003; - data[160]=(char)0x87e0; - data[161]=(char)0xfff9; - data[162]=(char)0xfdff; - data[163]=(char)0x036d; - data[165]=(char)0x5e00; - data[167]=(char)0x001c; - data[168]=(char)0xafe0; - data[169]=(char)0xfffb; - data[170]=(char)0xfdff; - data[171]=(char)0x23ed; - data[174]=(char)0x0001; - data[176]=(char)0x9fe0; - data[177]=(char)0xfff9; - data[178]=(char)0xfdff; - data[179]=(char)0x23cd; - data[181]=(char)0xb000; - data[182]=(char)0x0003; - data[184]=(char)0xc7e0; - data[185]=(char)0xd63d; - data[186]=(char)0xc718; - data[187]=(char)0x03bf; - data[192]=(char)0xdfe0; - data[193]=(char)0xfffd; - data[194]=(char)0xfdff; - data[195]=(char)0x03ef; - data[198]=(char)0x0003; - data[200]=(char)0xdfe0; - data[201]=(char)0xfffd; - data[202]=(char)0xfdff; - data[203]=(char)0x03ef; - data[205]=(char)0x4000; - data[206]=(char)0x0003; - data[208]=(char)0xdfe0; - data[209]=(char)0xfffd; - data[210]=(char)0xfdff; - data[211]=(char)0x03ff; - data[214]=(char)0x0003; - data[224]=(char)0xfffe; - data[225]=(char)0xffff; - data[226]=(char)0x7fff; - data[227]=(char)0x000d; - data[228]=(char)0x007f; - data[232]=(char)0x2596; - data[233]=(char)0xfef0; - data[234]=(char)0x6cae; - data[235]=(char)0x200d; - data[236]=(char)0x005f; - data[237]=(char)0x3000; - data[244]=(char)0xfeff; - data[245]=(char)0xffff; - data[246]=(char)0x03ff; - data[266]=(char)0xffff; - data[267]=(char)0xffff; - data[268]=(char)0x003f; - data[269]=(char)0xffff; - data[270]=(char)0xffff; - data[271]=(char)0x007f; - data[272]=(char)0xffff; - data[273]=(char)0xffff; - data[274]=(char)0xffff; - data[275]=(char)0xffff; - data[276]=(char)0xffff; - data[277]=(char)0x83ff; - data[278]=(char)0xffff; - data[279]=(char)0xffff; - data[280]=(char)0xffff; - data[281]=(char)0xffff; - data[282]=(char)0xff07; - data[283]=(char)0xffff; - data[284]=(char)0xffff; - data[285]=(char)0xffff; - data[286]=(char)0xffff; - data[287]=(char)0x03ff; - data[480]=(char)0xffff; - data[481]=(char)0xffff; - data[482]=(char)0xffff; - data[483]=(char)0xffff; - data[484]=(char)0xffff; - data[485]=(char)0xffff; - data[486]=(char)0xffff; - data[487]=(char)0xffff; - data[488]=(char)0xffff; - data[489]=(char)0x0fff; - data[490]=(char)0xffff; - data[491]=(char)0xffff; - data[492]=(char)0xffff; - data[493]=(char)0xffff; - data[494]=(char)0xffff; - data[495]=(char)0x03ff; - data[496]=(char)0xffff; - data[497]=(char)0x3f3f; - data[498]=(char)0xffff; - data[499]=(char)0xffff; - data[500]=(char)0x3f3f; - data[501]=(char)0xaaff; - data[502]=(char)0xffff; - data[503]=(char)0x3fff; - data[504]=(char)0xffff; - data[505]=(char)0xffff; - data[506]=(char)0xffff; - data[507]=(char)0x5fdf; - data[508]=(char)0x1fdc; - data[509]=(char)0x0fcf; - data[510]=(char)0x1fff; - data[511]=(char)0x1fdc; - data[519]=(char)0x8000; - data[528]=(char)0xfc84; - data[529]=(char)0x3f2f; - data[530]=(char)0xfd50; - data[531]=(char)0x01fb; - data[768]=(char)0x0020; - data[771]=(char)0x003e; - data[772]=(char)0xfffe; - data[773]=(char)0xffff; - data[774]=(char)0xffff; - data[775]=(char)0xffff; - data[776]=(char)0xffff; - data[777]=(char)0x781f; - data[778]=(char)0xfffe; - data[779]=(char)0xffff; - data[780]=(char)0xffff; - data[781]=(char)0xffff; - data[782]=(char)0xffff; - data[783]=(char)0x77ff; - data[784]=(char)0xffe0; - data[785]=(char)0xffff; - data[786]=(char)0x1fff; - data[787]=(char)0xfffe; - data[788]=(char)0xffff; - data[789]=(char)0xffff; - data[790]=(char)0xffff; - data[791]=(char)0xffff; - data[792]=(char)0x7fff; - data[1248]=(char)0xffff; - data[1249]=(char)0xffff; - data[1250]=(char)0xffff; - data[1251]=(char)0xffff; - data[1252]=(char)0xffff; - data[1253]=(char)0xffff; - data[1254]=(char)0xffff; - data[1255]=(char)0xffff; - data[1256]=(char)0xffff; - data[1257]=(char)0xffff; - data[1258]=(char)0xffff; - data[1259]=(char)0xffff; - data[1260]=(char)0xffff; - data[1261]=(char)0xffff; - data[1262]=(char)0xffff; - data[1263]=(char)0xffff; - data[1264]=(char)0xffff; - data[1265]=(char)0xffff; - data[1266]=(char)0xffff; - data[1267]=(char)0xffff; - data[1268]=(char)0xffff; - data[1269]=(char)0xffff; - data[1270]=(char)0xffff; - data[1271]=(char)0xffff; - data[1272]=(char)0xffff; - data[1273]=(char)0xffff; - data[1274]=(char)0xffff; - data[1275]=(char)0xffff; - data[1276]=(char)0xffff; - data[1277]=(char)0xffff; - data[1278]=(char)0xffff; - data[1279]=(char)0xffff; - data[1280]=(char)0xffff; - data[1281]=(char)0xffff; - data[1282]=(char)0xffff; - data[1283]=(char)0xffff; - data[1284]=(char)0xffff; - data[1285]=(char)0xffff; - data[1286]=(char)0xffff; - data[1287]=(char)0xffff; - data[1288]=(char)0xffff; - data[1289]=(char)0xffff; - data[1290]=(char)0xffff; - data[1291]=(char)0xffff; - data[1292]=(char)0xffff; - data[1293]=(char)0xffff; - data[1294]=(char)0xffff; - data[1295]=(char)0xffff; - data[1296]=(char)0xffff; - data[1297]=(char)0xffff; - data[1298]=(char)0xffff; - data[1299]=(char)0xffff; - data[1300]=(char)0xffff; - data[1301]=(char)0xffff; - data[1302]=(char)0xffff; - data[1303]=(char)0xffff; - data[1304]=(char)0xffff; - data[1305]=(char)0xffff; - data[1306]=(char)0xffff; - data[1307]=(char)0xffff; - data[1308]=(char)0xffff; - data[1309]=(char)0xffff; - data[1310]=(char)0xffff; - data[1311]=(char)0xffff; - data[1312]=(char)0xffff; - data[1313]=(char)0xffff; - data[1314]=(char)0xffff; - data[1315]=(char)0xffff; - data[1316]=(char)0xffff; - data[1317]=(char)0xffff; - data[1318]=(char)0xffff; - data[1319]=(char)0xffff; - data[1320]=(char)0xffff; - data[1321]=(char)0xffff; - data[1322]=(char)0xffff; - data[1323]=(char)0xffff; - data[1324]=(char)0xffff; - data[1325]=(char)0xffff; - data[1326]=(char)0xffff; - data[1327]=(char)0xffff; - data[1328]=(char)0xffff; - data[1329]=(char)0xffff; - data[1330]=(char)0xffff; - data[1331]=(char)0xffff; - data[1332]=(char)0xffff; - data[1333]=(char)0xffff; - data[1334]=(char)0xffff; - data[1335]=(char)0xffff; - data[1336]=(char)0xffff; - data[1337]=(char)0xffff; - data[1338]=(char)0xffff; - data[1339]=(char)0xffff; - data[1340]=(char)0xffff; - data[1341]=(char)0xffff; - data[1342]=(char)0xffff; - data[1343]=(char)0xffff; - data[1344]=(char)0xffff; - data[1345]=(char)0xffff; - data[1346]=(char)0xffff; - data[1347]=(char)0xffff; - data[1348]=(char)0xffff; - data[1349]=(char)0xffff; - data[1350]=(char)0xffff; - data[1351]=(char)0xffff; - data[1352]=(char)0xffff; - data[1353]=(char)0xffff; - data[1354]=(char)0xffff; - data[1355]=(char)0xffff; - data[1356]=(char)0xffff; - data[1357]=(char)0xffff; - data[1358]=(char)0xffff; - data[1359]=(char)0xffff; - data[1360]=(char)0xffff; - data[1361]=(char)0xffff; - data[1362]=(char)0xffff; - data[1363]=(char)0xffff; - data[1364]=(char)0xffff; - data[1365]=(char)0xffff; - data[1366]=(char)0xffff; - data[1367]=(char)0xffff; - data[1368]=(char)0xffff; - data[1369]=(char)0xffff; - data[1370]=(char)0xffff; - data[1371]=(char)0xffff; - data[1372]=(char)0xffff; - data[1373]=(char)0xffff; - data[1374]=(char)0xffff; - data[1375]=(char)0xffff; - data[1376]=(char)0xffff; - data[1377]=(char)0xffff; - data[1378]=(char)0xffff; - data[1379]=(char)0xffff; - data[1380]=(char)0xffff; - data[1381]=(char)0xffff; - data[1382]=(char)0xffff; - data[1383]=(char)0xffff; - data[1384]=(char)0xffff; - data[1385]=(char)0xffff; - data[1386]=(char)0xffff; - data[1387]=(char)0xffff; - data[1388]=(char)0xffff; - data[1389]=(char)0xffff; - data[1390]=(char)0xffff; - data[1391]=(char)0xffff; - data[1392]=(char)0xffff; - data[1393]=(char)0xffff; - data[1394]=(char)0xffff; - data[1395]=(char)0xffff; - data[1396]=(char)0xffff; - data[1397]=(char)0xffff; - data[1398]=(char)0xffff; - data[1399]=(char)0xffff; - data[1400]=(char)0xffff; - data[1401]=(char)0xffff; - data[1402]=(char)0xffff; - data[1403]=(char)0xffff; - data[1404]=(char)0xffff; - data[1405]=(char)0xffff; - data[1406]=(char)0xffff; - data[1407]=(char)0xffff; - data[1408]=(char)0xffff; - data[1409]=(char)0xffff; - data[1410]=(char)0xffff; - data[1411]=(char)0xffff; - data[1412]=(char)0xffff; - data[1413]=(char)0xffff; - data[1414]=(char)0xffff; - data[1415]=(char)0xffff; - data[1416]=(char)0xffff; - data[1417]=(char)0xffff; - data[1418]=(char)0xffff; - data[1419]=(char)0xffff; - data[1420]=(char)0xffff; - data[1421]=(char)0xffff; - data[1422]=(char)0xffff; - data[1423]=(char)0xffff; - data[1424]=(char)0xffff; - data[1425]=(char)0xffff; - data[1426]=(char)0xffff; - data[1427]=(char)0xffff; - data[1428]=(char)0xffff; - data[1429]=(char)0xffff; - data[1430]=(char)0xffff; - data[1431]=(char)0xffff; - data[1432]=(char)0xffff; - data[1433]=(char)0xffff; - data[1434]=(char)0xffff; - data[1435]=(char)0xffff; - data[1436]=(char)0xffff; - data[1437]=(char)0xffff; - data[1438]=(char)0xffff; - data[1439]=(char)0xffff; - data[1440]=(char)0xffff; - data[1441]=(char)0xffff; - data[1442]=(char)0xffff; - data[1443]=(char)0xffff; - data[1444]=(char)0xffff; - data[1445]=(char)0xffff; - data[1446]=(char)0xffff; - data[1447]=(char)0xffff; - data[1448]=(char)0xffff; - data[1449]=(char)0xffff; - data[1450]=(char)0xffff; - data[1451]=(char)0xffff; - data[1452]=(char)0xffff; - data[1453]=(char)0xffff; - data[1454]=(char)0xffff; - data[1455]=(char)0xffff; - data[1456]=(char)0xffff; - data[1457]=(char)0xffff; - data[1458]=(char)0xffff; - data[1459]=(char)0xffff; - data[1460]=(char)0xffff; - data[1461]=(char)0xffff; - data[1462]=(char)0xffff; - data[1463]=(char)0xffff; - data[1464]=(char)0xffff; - data[1465]=(char)0xffff; - data[1466]=(char)0xffff; - data[1467]=(char)0xffff; - data[1468]=(char)0xffff; - data[1469]=(char)0xffff; - data[1470]=(char)0xffff; - data[1471]=(char)0xffff; - data[1472]=(char)0xffff; - data[1473]=(char)0xffff; - data[1474]=(char)0xffff; - data[1475]=(char)0xffff; - data[1476]=(char)0xffff; - data[1477]=(char)0xffff; - data[1478]=(char)0xffff; - data[1479]=(char)0xffff; - data[1480]=(char)0xffff; - data[1481]=(char)0xffff; - data[1482]=(char)0xffff; - data[1483]=(char)0xffff; - data[1484]=(char)0xffff; - data[1485]=(char)0xffff; - data[1486]=(char)0xffff; - data[1487]=(char)0xffff; - data[1488]=(char)0xffff; - data[1489]=(char)0xffff; - data[1490]=(char)0xffff; - data[1491]=(char)0xffff; - data[1492]=(char)0xffff; - data[1493]=(char)0xffff; - data[1494]=(char)0xffff; - data[1495]=(char)0xffff; - data[1496]=(char)0xffff; - data[1497]=(char)0xffff; - data[1498]=(char)0xffff; - data[1499]=(char)0xffff; - data[1500]=(char)0xffff; - data[1501]=(char)0xffff; - data[1502]=(char)0xffff; - data[1503]=(char)0xffff; - data[1504]=(char)0xffff; - data[1505]=(char)0xffff; - data[1506]=(char)0xffff; - data[1507]=(char)0xffff; - data[1508]=(char)0xffff; - data[1509]=(char)0xffff; - data[1510]=(char)0xffff; - data[1511]=(char)0xffff; - data[1512]=(char)0xffff; - data[1513]=(char)0xffff; - data[1514]=(char)0xffff; - data[1515]=(char)0xffff; - data[1516]=(char)0xffff; - data[1517]=(char)0xffff; - data[1518]=(char)0xffff; - data[1519]=(char)0xffff; - data[1520]=(char)0xffff; - data[1521]=(char)0xffff; - data[1522]=(char)0xffff; - data[1523]=(char)0xffff; - data[1524]=(char)0xffff; - data[1525]=(char)0xffff; - data[1526]=(char)0xffff; - data[1527]=(char)0xffff; - data[1528]=(char)0xffff; - data[1529]=(char)0xffff; - data[1530]=(char)0xffff; - data[1531]=(char)0xffff; - data[1532]=(char)0xffff; - data[1533]=(char)0xffff; - data[1534]=(char)0xffff; - data[1535]=(char)0xffff; - data[1536]=(char)0xffff; - data[1537]=(char)0xffff; - data[1538]=(char)0xffff; - data[1539]=(char)0xffff; - data[1540]=(char)0xffff; - data[1541]=(char)0xffff; - data[1542]=(char)0xffff; - data[1543]=(char)0xffff; - data[1544]=(char)0xffff; - data[1545]=(char)0xffff; - data[1546]=(char)0xffff; - data[1547]=(char)0xffff; - data[1548]=(char)0xffff; - data[1549]=(char)0xffff; - data[1550]=(char)0xffff; - data[1551]=(char)0xffff; - data[1552]=(char)0xffff; - data[1553]=(char)0xffff; - data[1554]=(char)0xffff; - data[1555]=(char)0xffff; - data[1556]=(char)0xffff; - data[1557]=(char)0xffff; - data[1558]=(char)0xffff; - data[1559]=(char)0xffff; - data[1560]=(char)0xffff; - data[1561]=(char)0xffff; - data[1562]=(char)0xffff; - data[1563]=(char)0xffff; - data[1564]=(char)0xffff; - data[1565]=(char)0xffff; - data[1566]=(char)0xffff; - data[1567]=(char)0xffff; - data[1568]=(char)0xffff; - data[1569]=(char)0xffff; - data[1570]=(char)0xffff; - data[1571]=(char)0xffff; - data[1572]=(char)0xffff; - data[1573]=(char)0xffff; - data[1574]=(char)0xffff; - data[1575]=(char)0xffff; - data[1576]=(char)0xffff; - data[1577]=(char)0xffff; - data[1578]=(char)0xffff; - data[1579]=(char)0xffff; - data[1580]=(char)0xffff; - data[1581]=(char)0xffff; - data[1582]=(char)0xffff; - data[1583]=(char)0xffff; - data[1584]=(char)0xffff; - data[1585]=(char)0xffff; - data[1586]=(char)0xffff; - data[1587]=(char)0xffff; - data[1588]=(char)0xffff; - data[1589]=(char)0xffff; - data[1590]=(char)0xffff; - data[1591]=(char)0xffff; - data[1592]=(char)0xffff; - data[1593]=(char)0xffff; - data[1594]=(char)0xffff; - data[1595]=(char)0xffff; - data[1596]=(char)0xffff; - data[1597]=(char)0xffff; - data[1598]=(char)0xffff; - data[1599]=(char)0xffff; - data[1600]=(char)0xffff; - data[1601]=(char)0xffff; - data[1602]=(char)0xffff; - data[1603]=(char)0xffff; - data[1604]=(char)0xffff; - data[1605]=(char)0xffff; - data[1606]=(char)0xffff; - data[1607]=(char)0xffff; - data[1608]=(char)0xffff; - data[1609]=(char)0xffff; - data[1610]=(char)0xffff; - data[1611]=(char)0xffff; - data[1612]=(char)0xffff; - data[1613]=(char)0xffff; - data[1614]=(char)0xffff; - data[1615]=(char)0xffff; - data[1616]=(char)0xffff; - data[1617]=(char)0xffff; - data[1618]=(char)0xffff; - data[1619]=(char)0xffff; - data[1620]=(char)0xffff; - data[1621]=(char)0xffff; - data[1622]=(char)0xffff; - data[1623]=(char)0xffff; - data[1624]=(char)0xffff; - data[1625]=(char)0xffff; - data[1626]=(char)0xffff; - data[1627]=(char)0xffff; - data[1628]=(char)0xffff; - data[1629]=(char)0xffff; - data[1630]=(char)0xffff; - data[1631]=(char)0xffff; - data[1632]=(char)0xffff; - data[1633]=(char)0xffff; - data[1634]=(char)0xffff; - data[1635]=(char)0xffff; - data[1636]=(char)0xffff; - data[1637]=(char)0xffff; - data[1638]=(char)0xffff; - data[1639]=(char)0xffff; - data[1640]=(char)0xffff; - data[1641]=(char)0xffff; - data[1642]=(char)0xffff; - data[1643]=(char)0xffff; - data[1644]=(char)0xffff; - data[1645]=(char)0xffff; - data[1646]=(char)0xffff; - data[1647]=(char)0xffff; - data[1648]=(char)0xffff; - data[1649]=(char)0xffff; - data[1650]=(char)0xffff; - data[1651]=(char)0xffff; - data[1652]=(char)0xffff; - data[1653]=(char)0xffff; - data[1654]=(char)0xffff; - data[1655]=(char)0xffff; - data[1656]=(char)0xffff; - data[1657]=(char)0xffff; - data[1658]=(char)0xffff; - data[1659]=(char)0xffff; - data[1660]=(char)0xffff; - data[1661]=(char)0xffff; - data[1662]=(char)0xffff; - data[1663]=(char)0xffff; - data[1664]=(char)0xffff; - data[1665]=(char)0xffff; - data[1666]=(char)0xffff; - data[1667]=(char)0xffff; - data[1668]=(char)0xffff; - data[1669]=(char)0xffff; - data[1670]=(char)0xffff; - data[1671]=(char)0xffff; - data[1672]=(char)0xffff; - data[1673]=(char)0xffff; - data[1674]=(char)0xffff; - data[1675]=(char)0xffff; - data[1676]=(char)0xffff; - data[1677]=(char)0xffff; - data[1678]=(char)0xffff; - data[1679]=(char)0xffff; - data[1680]=(char)0xffff; - data[1681]=(char)0xffff; - data[1682]=(char)0xffff; - data[1683]=(char)0xffff; - data[1684]=(char)0xffff; - data[1685]=(char)0xffff; - data[1686]=(char)0xffff; - data[1687]=(char)0xffff; - data[1688]=(char)0xffff; - data[1689]=(char)0xffff; - data[1690]=(char)0xffff; - data[1691]=(char)0xffff; - data[1692]=(char)0xffff; - data[1693]=(char)0xffff; - data[1694]=(char)0xffff; - data[1695]=(char)0xffff; - data[1696]=(char)0xffff; - data[1697]=(char)0xffff; - data[1698]=(char)0xffff; - data[1699]=(char)0xffff; - data[1700]=(char)0xffff; - data[1701]=(char)0xffff; - data[1702]=(char)0xffff; - data[1703]=(char)0xffff; - data[1704]=(char)0xffff; - data[1705]=(char)0xffff; - data[1706]=(char)0xffff; - data[1707]=(char)0xffff; - data[1708]=(char)0xffff; - data[1709]=(char)0xffff; - data[1710]=(char)0xffff; - data[1711]=(char)0xffff; - data[1712]=(char)0xffff; - data[1713]=(char)0xffff; - data[1714]=(char)0xffff; - data[1715]=(char)0xffff; - data[1716]=(char)0xffff; - data[1717]=(char)0xffff; - data[1718]=(char)0xffff; - data[1719]=(char)0xffff; - data[1720]=(char)0xffff; - data[1721]=(char)0xffff; - data[1722]=(char)0xffff; - data[1723]=(char)0xffff; - data[1724]=(char)0xffff; - data[1725]=(char)0xffff; - data[1726]=(char)0xffff; - data[1727]=(char)0xffff; - data[1728]=(char)0xffff; - data[1729]=(char)0xffff; - data[1730]=(char)0xffff; - data[1731]=(char)0xffff; - data[1732]=(char)0xffff; - data[1733]=(char)0xffff; - data[1734]=(char)0xffff; - data[1735]=(char)0xffff; - data[1736]=(char)0xffff; - data[1737]=(char)0xffff; - data[1738]=(char)0xffff; - data[1739]=(char)0xffff; - data[1740]=(char)0xffff; - data[1741]=(char)0xffff; - data[1742]=(char)0xffff; - data[1743]=(char)0xffff; - data[1744]=(char)0xffff; - data[1745]=(char)0xffff; - data[1746]=(char)0xffff; - data[1747]=(char)0xffff; - data[1748]=(char)0xffff; - data[1749]=(char)0xffff; - data[1750]=(char)0xffff; - data[1751]=(char)0xffff; - data[1752]=(char)0xffff; - data[1753]=(char)0xffff; - data[1754]=(char)0xffff; - data[1755]=(char)0xffff; - data[1756]=(char)0xffff; - data[1757]=(char)0xffff; - data[1758]=(char)0xffff; - data[1759]=(char)0xffff; - data[1760]=(char)0xffff; - data[1761]=(char)0xffff; - data[1762]=(char)0xffff; - data[1763]=(char)0xffff; - data[1764]=(char)0xffff; - data[1765]=(char)0xffff; - data[1766]=(char)0xffff; - data[1767]=(char)0xffff; - data[1768]=(char)0xffff; - data[1769]=(char)0xffff; - data[1770]=(char)0xffff; - data[1771]=(char)0xffff; - data[1772]=(char)0xffff; - data[1773]=(char)0xffff; - data[1774]=(char)0xffff; - data[1775]=(char)0xffff; - data[1776]=(char)0xffff; - data[1777]=(char)0xffff; - data[1778]=(char)0xffff; - data[1779]=(char)0xffff; - data[1780]=(char)0xffff; - data[1781]=(char)0xffff; - data[1782]=(char)0xffff; - data[1783]=(char)0xffff; - data[1784]=(char)0xffff; - data[1785]=(char)0xffff; - data[1786]=(char)0xffff; - data[1787]=(char)0xffff; - data[1788]=(char)0xffff; - data[1789]=(char)0xffff; - data[1790]=(char)0xffff; - data[1791]=(char)0xffff; - data[1792]=(char)0xffff; - data[1793]=(char)0xffff; - data[1794]=(char)0xffff; - data[1795]=(char)0xffff; - data[1796]=(char)0xffff; - data[1797]=(char)0xffff; - data[1798]=(char)0xffff; - data[1799]=(char)0xffff; - data[1800]=(char)0xffff; - data[1801]=(char)0xffff; - data[1802]=(char)0xffff; - data[1803]=(char)0xffff; - data[1804]=(char)0xffff; - data[1805]=(char)0xffff; - data[1806]=(char)0xffff; - data[1807]=(char)0xffff; - data[1808]=(char)0xffff; - data[1809]=(char)0xffff; - data[1810]=(char)0xffff; - data[1811]=(char)0xffff; - data[1812]=(char)0xffff; - data[1813]=(char)0xffff; - data[1814]=(char)0xffff; - data[1815]=(char)0xffff; - data[1816]=(char)0xffff; - data[1817]=(char)0xffff; - data[1818]=(char)0xffff; - data[1819]=(char)0xffff; - data[1820]=(char)0xffff; - data[1821]=(char)0xffff; - data[1822]=(char)0xffff; - data[1823]=(char)0xffff; - data[1824]=(char)0xffff; - data[1825]=(char)0xffff; - data[1826]=(char)0xffff; - data[1827]=(char)0xffff; - data[1828]=(char)0xffff; - data[1829]=(char)0xffff; - data[1830]=(char)0xffff; - data[1831]=(char)0xffff; - data[1832]=(char)0xffff; - data[1833]=(char)0xffff; - data[1834]=(char)0xffff; - data[1835]=(char)0xffff; - data[1836]=(char)0xffff; - data[1837]=(char)0xffff; - data[1838]=(char)0xffff; - data[1839]=(char)0xffff; - data[1840]=(char)0xffff; - data[1841]=(char)0xffff; - data[1842]=(char)0xffff; - data[1843]=(char)0xffff; - data[1844]=(char)0xffff; - data[1845]=(char)0xffff; - data[1846]=(char)0xffff; - data[1847]=(char)0xffff; - data[1848]=(char)0xffff; - data[1849]=(char)0xffff; - data[1850]=(char)0xffff; - data[1851]=(char)0xffff; - data[1852]=(char)0xffff; - data[1853]=(char)0xffff; - data[1854]=(char)0xffff; - data[1855]=(char)0xffff; - data[1856]=(char)0xffff; - data[1857]=(char)0xffff; - data[1858]=(char)0xffff; - data[1859]=(char)0xffff; - data[1860]=(char)0xffff; - data[1861]=(char)0xffff; - data[1862]=(char)0xffff; - data[1863]=(char)0xffff; - data[1864]=(char)0xffff; - data[1865]=(char)0xffff; - data[1866]=(char)0xffff; - data[1867]=(char)0xffff; - data[1868]=(char)0xffff; - data[1869]=(char)0xffff; - data[1870]=(char)0xffff; - data[1871]=(char)0xffff; - data[1872]=(char)0xffff; - data[1873]=(char)0xffff; - data[1874]=(char)0xffff; - data[1875]=(char)0xffff; - data[1876]=(char)0xffff; - data[1877]=(char)0xffff; - data[1878]=(char)0xffff; - data[1879]=(char)0xffff; - data[1880]=(char)0xffff; - data[1881]=(char)0xffff; - data[1882]=(char)0xffff; - data[1883]=(char)0xffff; - data[1884]=(char)0xffff; - data[1885]=(char)0xffff; - data[1886]=(char)0xffff; - data[1887]=(char)0xffff; - data[1888]=(char)0xffff; - data[1889]=(char)0xffff; - data[1890]=(char)0xffff; - data[1891]=(char)0xffff; - data[1892]=(char)0xffff; - data[1893]=(char)0xffff; - data[1894]=(char)0xffff; - data[1895]=(char)0xffff; - data[1896]=(char)0xffff; - data[1897]=(char)0xffff; - data[1898]=(char)0xffff; - data[1899]=(char)0xffff; - data[1900]=(char)0xffff; - data[1901]=(char)0xffff; - data[1902]=(char)0xffff; - data[1903]=(char)0xffff; - data[1904]=(char)0xffff; - data[1905]=(char)0xffff; - data[1906]=(char)0xffff; - data[1907]=(char)0xffff; - data[1908]=(char)0xffff; - data[1909]=(char)0xffff; - data[1910]=(char)0xffff; - data[1911]=(char)0xffff; - data[1912]=(char)0xffff; - data[1913]=(char)0xffff; - data[1914]=(char)0xffff; - data[1915]=(char)0xffff; - data[1916]=(char)0xffff; - data[1917]=(char)0xffff; - data[1918]=(char)0xffff; - data[1919]=(char)0xffff; - data[1920]=(char)0xffff; - data[1921]=(char)0xffff; - data[1922]=(char)0xffff; - data[1923]=(char)0xffff; - data[1924]=(char)0xffff; - data[1925]=(char)0xffff; - data[1926]=(char)0xffff; - data[1927]=(char)0xffff; - data[1928]=(char)0xffff; - data[1929]=(char)0xffff; - data[1930]=(char)0xffff; - data[1931]=(char)0xffff; - data[1932]=(char)0xffff; - data[1933]=(char)0xffff; - data[1934]=(char)0xffff; - data[1935]=(char)0xffff; - data[1936]=(char)0xffff; - data[1937]=(char)0xffff; - data[1938]=(char)0xffff; - data[1939]=(char)0xffff; - data[1940]=(char)0xffff; - data[1941]=(char)0xffff; - data[1942]=(char)0xffff; - data[1943]=(char)0xffff; - data[1944]=(char)0xffff; - data[1945]=(char)0xffff; - data[1946]=(char)0xffff; - data[1947]=(char)0xffff; - data[1948]=(char)0xffff; - data[1949]=(char)0xffff; - data[1950]=(char)0xffff; - data[1951]=(char)0xffff; - data[1952]=(char)0xffff; - data[1953]=(char)0xffff; - data[1954]=(char)0xffff; - data[1955]=(char)0xffff; - data[1956]=(char)0xffff; - data[1957]=(char)0xffff; - data[1958]=(char)0xffff; - data[1959]=(char)0xffff; - data[1960]=(char)0xffff; - data[1961]=(char)0xffff; - data[1962]=(char)0xffff; - data[1963]=(char)0xffff; - data[1964]=(char)0xffff; - data[1965]=(char)0xffff; - data[1966]=(char)0xffff; - data[1967]=(char)0xffff; - data[1968]=(char)0xffff; - data[1969]=(char)0xffff; - data[1970]=(char)0xffff; - data[1971]=(char)0xffff; - data[1972]=(char)0xffff; - data[1973]=(char)0xffff; - data[1974]=(char)0xffff; - data[1975]=(char)0xffff; - data[1976]=(char)0xffff; - data[1977]=(char)0xffff; - data[1978]=(char)0xffff; - data[1979]=(char)0xffff; - data[1980]=(char)0xffff; - data[1981]=(char)0xffff; - data[1982]=(char)0xffff; - data[1983]=(char)0xffff; - data[1984]=(char)0xffff; - data[1985]=(char)0xffff; - data[1986]=(char)0xffff; - data[1987]=(char)0xffff; - data[1988]=(char)0xffff; - data[1989]=(char)0xffff; - data[1990]=(char)0xffff; - data[1991]=(char)0xffff; - data[1992]=(char)0xffff; - data[1993]=(char)0xffff; - data[1994]=(char)0xffff; - data[1995]=(char)0xffff; - data[1996]=(char)0xffff; - data[1997]=(char)0xffff; - data[1998]=(char)0xffff; - data[1999]=(char)0xffff; - data[2000]=(char)0xffff; - data[2001]=(char)0xffff; - data[2002]=(char)0xffff; - data[2003]=(char)0xffff; - data[2004]=(char)0xffff; - data[2005]=(char)0xffff; - data[2006]=(char)0xffff; - data[2007]=(char)0xffff; - data[2008]=(char)0xffff; - data[2009]=(char)0xffff; - data[2010]=(char)0xffff; - data[2011]=(char)0xffff; - data[2012]=(char)0xffff; - data[2013]=(char)0xffff; - data[2014]=(char)0xffff; - data[2015]=(char)0xffff; - data[2016]=(char)0xffff; - data[2017]=(char)0xffff; - data[2018]=(char)0xffff; - data[2019]=(char)0xffff; - data[2020]=(char)0xffff; - data[2021]=(char)0xffff; - data[2022]=(char)0xffff; - data[2023]=(char)0xffff; - data[2024]=(char)0xffff; - data[2025]=(char)0xffff; - data[2026]=(char)0xffff; - data[2027]=(char)0xffff; - data[2028]=(char)0xffff; - data[2029]=(char)0xffff; - data[2030]=(char)0xffff; - data[2031]=(char)0xffff; - data[2032]=(char)0xffff; - data[2033]=(char)0xffff; - data[2034]=(char)0xffff; - data[2035]=(char)0xffff; - data[2036]=(char)0xffff; - data[2037]=(char)0xffff; - data[2038]=(char)0xffff; - data[2039]=(char)0xffff; - data[2040]=(char)0xffff; - data[2041]=(char)0xffff; - data[2042]=(char)0xffff; - data[2043]=(char)0xffff; - data[2044]=(char)0xffff; - data[2045]=(char)0xffff; - data[2046]=(char)0xffff; - data[2047]=(char)0xffff; - data[2048]=(char)0xffff; - data[2049]=(char)0xffff; - data[2050]=(char)0xffff; - data[2051]=(char)0xffff; - data[2052]=(char)0xffff; - data[2053]=(char)0xffff; - data[2054]=(char)0xffff; - data[2055]=(char)0xffff; - data[2056]=(char)0xffff; - data[2057]=(char)0xffff; - data[2058]=(char)0xffff; - data[2059]=(char)0xffff; - data[2060]=(char)0xffff; - data[2061]=(char)0xffff; - data[2062]=(char)0xffff; - data[2063]=(char)0xffff; - data[2064]=(char)0xffff; - data[2065]=(char)0xffff; - data[2066]=(char)0xffff; - data[2067]=(char)0xffff; - data[2068]=(char)0xffff; - data[2069]=(char)0xffff; - data[2070]=(char)0xffff; - data[2071]=(char)0xffff; - data[2072]=(char)0xffff; - data[2073]=(char)0xffff; - data[2074]=(char)0xffff; - data[2075]=(char)0xffff; - data[2076]=(char)0xffff; - data[2077]=(char)0xffff; - data[2078]=(char)0xffff; - data[2079]=(char)0xffff; - data[2080]=(char)0xffff; - data[2081]=(char)0xffff; - data[2082]=(char)0xffff; - data[2083]=(char)0xffff; - data[2084]=(char)0xffff; - data[2085]=(char)0xffff; - data[2086]=(char)0xffff; - data[2087]=(char)0xffff; - data[2088]=(char)0xffff; - data[2089]=(char)0xffff; - data[2090]=(char)0xffff; - data[2091]=(char)0xffff; - data[2092]=(char)0xffff; - data[2093]=(char)0xffff; - data[2094]=(char)0xffff; - data[2095]=(char)0xffff; - data[2096]=(char)0xffff; - data[2097]=(char)0xffff; - data[2098]=(char)0xffff; - data[2099]=(char)0xffff; - data[2100]=(char)0xffff; - data[2101]=(char)0xffff; - data[2102]=(char)0xffff; - data[2103]=(char)0xffff; - data[2104]=(char)0xffff; - data[2105]=(char)0xffff; - data[2106]=(char)0xffff; - data[2107]=(char)0xffff; - data[2108]=(char)0xffff; - data[2109]=(char)0xffff; - data[2110]=(char)0xffff; - data[2111]=(char)0xffff; - data[2112]=(char)0xffff; - data[2113]=(char)0xffff; - data[2114]=(char)0xffff; - data[2115]=(char)0xffff; - data[2116]=(char)0xffff; - data[2117]=(char)0xffff; - data[2118]=(char)0xffff; - data[2119]=(char)0xffff; - data[2120]=(char)0xffff; - data[2121]=(char)0xffff; - data[2122]=(char)0xffff; - data[2123]=(char)0xffff; - data[2124]=(char)0xffff; - data[2125]=(char)0xffff; - data[2126]=(char)0xffff; - data[2127]=(char)0xffff; - data[2128]=(char)0xffff; - data[2129]=(char)0xffff; - data[2130]=(char)0xffff; - data[2131]=(char)0xffff; - data[2132]=(char)0xffff; - data[2133]=(char)0xffff; - data[2134]=(char)0xffff; - data[2135]=(char)0xffff; - data[2136]=(char)0xffff; - data[2137]=(char)0xffff; - data[2138]=(char)0xffff; - data[2139]=(char)0xffff; - data[2140]=(char)0xffff; - data[2141]=(char)0xffff; - data[2142]=(char)0xffff; - data[2143]=(char)0xffff; - data[2144]=(char)0xffff; - data[2145]=(char)0xffff; - data[2146]=(char)0xffff; - data[2147]=(char)0xffff; - data[2148]=(char)0xffff; - data[2149]=(char)0xffff; - data[2150]=(char)0xffff; - data[2151]=(char)0xffff; - data[2152]=(char)0xffff; - data[2153]=(char)0xffff; - data[2154]=(char)0xffff; - data[2155]=(char)0xffff; - data[2156]=(char)0xffff; - data[2157]=(char)0xffff; - data[2158]=(char)0xffff; - data[2159]=(char)0xffff; - data[2160]=(char)0xffff; - data[2161]=(char)0xffff; - data[2162]=(char)0xffff; - data[2163]=(char)0xffff; - data[2164]=(char)0xffff; - data[2165]=(char)0xffff; - data[2166]=(char)0xffff; - data[2167]=(char)0xffff; - data[2168]=(char)0xffff; - data[2169]=(char)0xffff; - data[2170]=(char)0xffff; - data[2171]=(char)0xffff; - data[2172]=(char)0xffff; - data[2173]=(char)0xffff; - data[2174]=(char)0xffff; - data[2175]=(char)0xffff; - data[2176]=(char)0xffff; - data[2177]=(char)0xffff; - data[2178]=(char)0xffff; - data[2179]=(char)0xffff; - data[2180]=(char)0xffff; - data[2181]=(char)0xffff; - data[2182]=(char)0xffff; - data[2183]=(char)0xffff; - data[2184]=(char)0xffff; - data[2185]=(char)0xffff; - data[2186]=(char)0xffff; - data[2187]=(char)0xffff; - data[2188]=(char)0xffff; - data[2189]=(char)0xffff; - data[2190]=(char)0xffff; - data[2191]=(char)0xffff; - data[2192]=(char)0xffff; - data[2193]=(char)0xffff; - data[2194]=(char)0xffff; - data[2195]=(char)0xffff; - data[2196]=(char)0xffff; - data[2197]=(char)0xffff; - data[2198]=(char)0xffff; - data[2199]=(char)0xffff; - data[2200]=(char)0xffff; - data[2201]=(char)0xffff; - data[2202]=(char)0xffff; - data[2203]=(char)0xffff; - data[2204]=(char)0xffff; - data[2205]=(char)0xffff; - data[2206]=(char)0xffff; - data[2207]=(char)0xffff; - data[2208]=(char)0xffff; - data[2209]=(char)0xffff; - data[2210]=(char)0xffff; - data[2211]=(char)0xffff; - data[2212]=(char)0xffff; - data[2213]=(char)0xffff; - data[2214]=(char)0xffff; - data[2215]=(char)0xffff; - data[2216]=(char)0xffff; - data[2217]=(char)0xffff; - data[2218]=(char)0xffff; - data[2219]=(char)0xffff; - data[2220]=(char)0xffff; - data[2221]=(char)0xffff; - data[2222]=(char)0xffff; - data[2223]=(char)0xffff; - data[2224]=(char)0xffff; - data[2225]=(char)0xffff; - data[2226]=(char)0xffff; - data[2227]=(char)0xffff; - data[2228]=(char)0xffff; - data[2229]=(char)0xffff; - data[2230]=(char)0xffff; - data[2231]=(char)0xffff; - data[2232]=(char)0xffff; - data[2233]=(char)0xffff; - data[2234]=(char)0xffff; - data[2235]=(char)0xffff; - data[2236]=(char)0xffff; - data[2237]=(char)0xffff; - data[2238]=(char)0xffff; - data[2239]=(char)0xffff; - data[2240]=(char)0xffff; - data[2241]=(char)0xffff; - data[2242]=(char)0xffff; - data[2243]=(char)0xffff; - data[2244]=(char)0xffff; - data[2245]=(char)0xffff; - data[2246]=(char)0xffff; - data[2247]=(char)0xffff; - data[2248]=(char)0xffff; - data[2249]=(char)0xffff; - data[2250]=(char)0xffff; - data[2251]=(char)0xffff; - data[2252]=(char)0xffff; - data[2253]=(char)0xffff; - data[2254]=(char)0xffff; - data[2255]=(char)0xffff; - data[2256]=(char)0xffff; - data[2257]=(char)0xffff; - data[2258]=(char)0xffff; - data[2259]=(char)0xffff; - data[2260]=(char)0xffff; - data[2261]=(char)0xffff; - data[2262]=(char)0xffff; - data[2263]=(char)0xffff; - data[2264]=(char)0xffff; - data[2265]=(char)0xffff; - data[2266]=(char)0xffff; - data[2267]=(char)0xffff; - data[2268]=(char)0xffff; - data[2269]=(char)0xffff; - data[2270]=(char)0xffff; - data[2271]=(char)0xffff; - data[2272]=(char)0xffff; - data[2273]=(char)0xffff; - data[2274]=(char)0xffff; - data[2275]=(char)0xffff; - data[2276]=(char)0xffff; - data[2277]=(char)0xffff; - data[2278]=(char)0xffff; - data[2279]=(char)0xffff; - data[2280]=(char)0xffff; - data[2281]=(char)0xffff; - data[2282]=(char)0xffff; - data[2283]=(char)0xffff; - data[2284]=(char)0xffff; - data[2285]=(char)0xffff; - data[2286]=(char)0xffff; - data[2287]=(char)0xffff; - data[2288]=(char)0xffff; - data[2289]=(char)0xffff; - data[2290]=(char)0xffff; - data[2291]=(char)0xffff; - data[2292]=(char)0xffff; - data[2293]=(char)0xffff; - data[2294]=(char)0xffff; - data[2295]=(char)0xffff; - data[2296]=(char)0xffff; - data[2297]=(char)0xffff; - data[2298]=(char)0xffff; - data[2299]=(char)0xffff; - data[2300]=(char)0xffff; - data[2301]=(char)0xffff; - data[2302]=(char)0xffff; - data[2303]=(char)0xffff; - data[2304]=(char)0xffff; - data[2305]=(char)0xffff; - data[2306]=(char)0xffff; - data[2307]=(char)0xffff; - data[2308]=(char)0xffff; - data[2309]=(char)0xffff; - data[2310]=(char)0xffff; - data[2311]=(char)0xffff; - data[2312]=(char)0xffff; - data[2313]=(char)0xffff; - data[2314]=(char)0xffff; - data[2315]=(char)0xffff; - data[2316]=(char)0xffff; - data[2317]=(char)0xffff; - data[2318]=(char)0xffff; - data[2319]=(char)0xffff; - data[2320]=(char)0xffff; - data[2321]=(char)0xffff; - data[2322]=(char)0xffff; - data[2323]=(char)0xffff; - data[2324]=(char)0xffff; - data[2325]=(char)0xffff; - data[2326]=(char)0xffff; - data[2327]=(char)0xffff; - data[2328]=(char)0xffff; - data[2329]=(char)0xffff; - data[2330]=(char)0xffff; - data[2331]=(char)0xffff; - data[2332]=(char)0xffff; - data[2333]=(char)0xffff; - data[2334]=(char)0xffff; - data[2335]=(char)0xffff; - data[2336]=(char)0xffff; - data[2337]=(char)0xffff; - data[2338]=(char)0xffff; - data[2339]=(char)0xffff; - data[2340]=(char)0xffff; - data[2341]=(char)0xffff; - data[2342]=(char)0xffff; - data[2343]=(char)0xffff; - data[2344]=(char)0xffff; - data[2345]=(char)0xffff; - data[2346]=(char)0xffff; - data[2347]=(char)0xffff; - data[2348]=(char)0xffff; - data[2349]=(char)0xffff; - data[2350]=(char)0xffff; - data[2351]=(char)0xffff; - data[2352]=(char)0xffff; - data[2353]=(char)0xffff; - data[2354]=(char)0xffff; - data[2355]=(char)0xffff; - data[2356]=(char)0xffff; - data[2357]=(char)0xffff; - data[2358]=(char)0xffff; - data[2359]=(char)0xffff; - data[2360]=(char)0xffff; - data[2361]=(char)0xffff; - data[2362]=(char)0xffff; - data[2363]=(char)0xffff; - data[2364]=(char)0xffff; - data[2365]=(char)0xffff; - data[2366]=(char)0xffff; - data[2367]=(char)0xffff; - data[2368]=(char)0xffff; - data[2369]=(char)0xffff; - data[2370]=(char)0xffff; - data[2371]=(char)0xffff; - data[2372]=(char)0xffff; - data[2373]=(char)0xffff; - data[2374]=(char)0xffff; - data[2375]=(char)0xffff; - data[2376]=(char)0xffff; - data[2377]=(char)0xffff; - data[2378]=(char)0xffff; - data[2379]=(char)0xffff; - data[2380]=(char)0xffff; - data[2381]=(char)0xffff; - data[2382]=(char)0xffff; - data[2383]=(char)0xffff; - data[2384]=(char)0xffff; - data[2385]=(char)0xffff; - data[2386]=(char)0xffff; - data[2387]=(char)0xffff; - data[2388]=(char)0xffff; - data[2389]=(char)0xffff; - data[2390]=(char)0xffff; - data[2391]=(char)0xffff; - data[2392]=(char)0xffff; - data[2393]=(char)0xffff; - data[2394]=(char)0xffff; - data[2395]=(char)0xffff; - data[2396]=(char)0xffff; - data[2397]=(char)0xffff; - data[2398]=(char)0xffff; - data[2399]=(char)0xffff; - data[2400]=(char)0xffff; - data[2401]=(char)0xffff; - data[2402]=(char)0xffff; - data[2403]=(char)0xffff; - data[2404]=(char)0xffff; - data[2405]=(char)0xffff; - data[2406]=(char)0xffff; - data[2407]=(char)0xffff; - data[2408]=(char)0xffff; - data[2409]=(char)0xffff; - data[2410]=(char)0xffff; - data[2411]=(char)0xffff; - data[2412]=(char)0xffff; - data[2413]=(char)0xffff; - data[2414]=(char)0xffff; - data[2415]=(char)0xffff; - data[2416]=(char)0xffff; - data[2417]=(char)0xffff; - data[2418]=(char)0xffff; - data[2419]=(char)0xffff; - data[2420]=(char)0xffff; - data[2421]=(char)0xffff; - data[2422]=(char)0xffff; - data[2423]=(char)0xffff; - data[2424]=(char)0xffff; - data[2425]=(char)0xffff; - data[2426]=(char)0xffff; - data[2427]=(char)0xffff; - data[2428]=(char)0xffff; - data[2429]=(char)0xffff; - data[2430]=(char)0xffff; - data[2431]=(char)0xffff; - data[2432]=(char)0xffff; - data[2433]=(char)0xffff; - data[2434]=(char)0xffff; - data[2435]=(char)0xffff; - data[2436]=(char)0xffff; - data[2437]=(char)0xffff; - data[2438]=(char)0xffff; - data[2439]=(char)0xffff; - data[2440]=(char)0xffff; - data[2441]=(char)0xffff; - data[2442]=(char)0xffff; - data[2443]=(char)0xffff; - data[2444]=(char)0xffff; - data[2445]=(char)0xffff; - data[2446]=(char)0xffff; - data[2447]=(char)0xffff; - data[2448]=(char)0xffff; - data[2449]=(char)0xffff; - data[2450]=(char)0xffff; - data[2451]=(char)0xffff; - data[2452]=(char)0xffff; - data[2453]=(char)0xffff; - data[2454]=(char)0xffff; - data[2455]=(char)0xffff; - data[2456]=(char)0xffff; - data[2457]=(char)0xffff; - data[2458]=(char)0xffff; - data[2459]=(char)0xffff; - data[2460]=(char)0xffff; - data[2461]=(char)0xffff; - data[2462]=(char)0xffff; - data[2463]=(char)0xffff; - data[2464]=(char)0xffff; - data[2465]=(char)0xffff; - data[2466]=(char)0xffff; - data[2467]=(char)0xffff; - data[2468]=(char)0xffff; - data[2469]=(char)0xffff; - data[2470]=(char)0xffff; - data[2471]=(char)0xffff; - data[2472]=(char)0xffff; - data[2473]=(char)0xffff; - data[2474]=(char)0xffff; - data[2475]=(char)0xffff; - data[2476]=(char)0xffff; - data[2477]=(char)0xffff; - data[2478]=(char)0xffff; - data[2479]=(char)0xffff; - data[2480]=(char)0xffff; - data[2481]=(char)0xffff; - data[2482]=(char)0xffff; - data[2483]=(char)0xffff; - data[2484]=(char)0xffff; - data[2485]=(char)0xffff; - data[2486]=(char)0xffff; - data[2487]=(char)0xffff; - data[2488]=(char)0xffff; - data[2489]=(char)0xffff; - data[2490]=(char)0xffff; - data[2491]=(char)0xffff; - data[2492]=(char)0xffff; - data[2493]=(char)0xffff; - data[2494]=(char)0xffff; - data[2495]=(char)0xffff; - data[2496]=(char)0xffff; - data[2497]=(char)0xffff; - data[2498]=(char)0xffff; - data[2499]=(char)0xffff; - data[2500]=(char)0xffff; - data[2501]=(char)0xffff; - data[2502]=(char)0xffff; - data[2503]=(char)0xffff; - data[2504]=(char)0xffff; - data[2505]=(char)0xffff; - data[2506]=(char)0xffff; - data[2507]=(char)0xffff; - data[2508]=(char)0xffff; - data[2509]=(char)0xffff; - data[2510]=(char)0xffff; - data[2511]=(char)0xffff; - data[2512]=(char)0xffff; - data[2513]=(char)0xffff; - data[2514]=(char)0xffff; - data[2515]=(char)0xffff; - data[2516]=(char)0xffff; - data[2517]=(char)0xffff; - data[2518]=(char)0xffff; - data[2519]=(char)0xffff; - data[2520]=(char)0xffff; - data[2521]=(char)0xffff; - data[2522]=(char)0xffff; - data[2523]=(char)0xffff; - data[2524]=(char)0xffff; - data[2525]=(char)0xffff; - data[2526]=(char)0xffff; - data[2527]=(char)0xffff; - data[2528]=(char)0xffff; - data[2529]=(char)0xffff; - data[2530]=(char)0xffff; - data[2531]=(char)0xffff; - data[2532]=(char)0xffff; - data[2533]=(char)0xffff; - data[2534]=(char)0xffff; - data[2535]=(char)0xffff; - data[2536]=(char)0xffff; - data[2537]=(char)0xffff; - data[2538]=(char)0xffff; - data[2539]=(char)0xffff; - data[2540]=(char)0xffff; - data[2541]=(char)0xffff; - data[2542]=(char)0xffff; - data[2543]=(char)0xffff; - data[2544]=(char)0xffff; - data[2545]=(char)0xffff; - data[2546]=(char)0xffff; - data[2547]=(char)0xffff; - data[2548]=(char)0xffff; - data[2549]=(char)0xffff; - data[2550]=(char)0xffff; - data[2551]=(char)0xffff; - data[2552]=(char)0xffff; - data[2553]=(char)0xffff; - data[2554]=(char)0x003f; - data[2752]=(char)0xffff; - data[2753]=(char)0xffff; - data[2754]=(char)0xffff; - data[2755]=(char)0xffff; - data[2756]=(char)0xffff; - data[2757]=(char)0xffff; - data[2758]=(char)0xffff; - data[2759]=(char)0xffff; - data[2760]=(char)0xffff; - data[2761]=(char)0xffff; - data[2762]=(char)0xffff; - data[2763]=(char)0xffff; - data[2764]=(char)0xffff; - data[2765]=(char)0xffff; - data[2766]=(char)0xffff; - data[2767]=(char)0xffff; - data[2768]=(char)0xffff; - data[2769]=(char)0xffff; - data[2770]=(char)0xffff; - data[2771]=(char)0xffff; - data[2772]=(char)0xffff; - data[2773]=(char)0xffff; - data[2774]=(char)0xffff; - data[2775]=(char)0xffff; - data[2776]=(char)0xffff; - data[2777]=(char)0xffff; - data[2778]=(char)0xffff; - data[2779]=(char)0xffff; - data[2780]=(char)0xffff; - data[2781]=(char)0xffff; - data[2782]=(char)0xffff; - data[2783]=(char)0xffff; - data[2784]=(char)0xffff; - data[2785]=(char)0xffff; - data[2786]=(char)0xffff; - data[2787]=(char)0xffff; - data[2788]=(char)0xffff; - data[2789]=(char)0xffff; - data[2790]=(char)0xffff; - data[2791]=(char)0xffff; - data[2792]=(char)0xffff; - data[2793]=(char)0xffff; - data[2794]=(char)0xffff; - data[2795]=(char)0xffff; - data[2796]=(char)0xffff; - data[2797]=(char)0xffff; - data[2798]=(char)0xffff; - data[2799]=(char)0xffff; - data[2800]=(char)0xffff; - data[2801]=(char)0xffff; - data[2802]=(char)0xffff; - data[2803]=(char)0xffff; - data[2804]=(char)0xffff; - data[2805]=(char)0xffff; - data[2806]=(char)0xffff; - data[2807]=(char)0xffff; - data[2808]=(char)0xffff; - data[2809]=(char)0xffff; - data[2810]=(char)0xffff; - data[2811]=(char)0xffff; - data[2812]=(char)0xffff; - data[2813]=(char)0xffff; - data[2814]=(char)0xffff; - data[2815]=(char)0xffff; - data[2816]=(char)0xffff; - data[2817]=(char)0xffff; - data[2818]=(char)0xffff; - data[2819]=(char)0xffff; - data[2820]=(char)0xffff; - data[2821]=(char)0xffff; - data[2822]=(char)0xffff; - data[2823]=(char)0xffff; - data[2824]=(char)0xffff; - data[2825]=(char)0xffff; - data[2826]=(char)0xffff; - data[2827]=(char)0xffff; - data[2828]=(char)0xffff; - data[2829]=(char)0xffff; - data[2830]=(char)0xffff; - data[2831]=(char)0xffff; - data[2832]=(char)0xffff; - data[2833]=(char)0xffff; - data[2834]=(char)0xffff; - data[2835]=(char)0xffff; - data[2836]=(char)0xffff; - data[2837]=(char)0xffff; - data[2838]=(char)0xffff; - data[2839]=(char)0xffff; - data[2840]=(char)0xffff; - data[2841]=(char)0xffff; - data[2842]=(char)0xffff; - data[2843]=(char)0xffff; - data[2844]=(char)0xffff; - data[2845]=(char)0xffff; - data[2846]=(char)0xffff; - data[2847]=(char)0xffff; - data[2848]=(char)0xffff; - data[2849]=(char)0xffff; - data[2850]=(char)0xffff; - data[2851]=(char)0xffff; - data[2852]=(char)0xffff; - data[2853]=(char)0xffff; - data[2854]=(char)0xffff; - data[2855]=(char)0xffff; - data[2856]=(char)0xffff; - data[2857]=(char)0xffff; - data[2858]=(char)0xffff; - data[2859]=(char)0xffff; - data[2860]=(char)0xffff; - data[2861]=(char)0xffff; - data[2862]=(char)0xffff; - data[2863]=(char)0xffff; - data[2864]=(char)0xffff; - data[2865]=(char)0xffff; - data[2866]=(char)0xffff; - data[2867]=(char)0xffff; - data[2868]=(char)0xffff; - data[2869]=(char)0xffff; - data[2870]=(char)0xffff; - data[2871]=(char)0xffff; - data[2872]=(char)0xffff; - data[2873]=(char)0xffff; - data[2874]=(char)0xffff; - data[2875]=(char)0xffff; - data[2876]=(char)0xffff; - data[2877]=(char)0xffff; - data[2878]=(char)0xffff; - data[2879]=(char)0xffff; - data[2880]=(char)0xffff; - data[2881]=(char)0xffff; - data[2882]=(char)0xffff; - data[2883]=(char)0xffff; - data[2884]=(char)0xffff; - data[2885]=(char)0xffff; - data[2886]=(char)0xffff; - data[2887]=(char)0xffff; - data[2888]=(char)0xffff; - data[2889]=(char)0xffff; - data[2890]=(char)0xffff; - data[2891]=(char)0xffff; - data[2892]=(char)0xffff; - data[2893]=(char)0xffff; - data[2894]=(char)0xffff; - data[2895]=(char)0xffff; - data[2896]=(char)0xffff; - data[2897]=(char)0xffff; - data[2898]=(char)0xffff; - data[2899]=(char)0xffff; - data[2900]=(char)0xffff; - data[2901]=(char)0xffff; - data[2902]=(char)0xffff; - data[2903]=(char)0xffff; - data[2904]=(char)0xffff; - data[2905]=(char)0xffff; - data[2906]=(char)0xffff; - data[2907]=(char)0xffff; - data[2908]=(char)0xffff; - data[2909]=(char)0xffff; - data[2910]=(char)0xffff; - data[2911]=(char)0xffff; - data[2912]=(char)0xffff; - data[2913]=(char)0xffff; - data[2914]=(char)0xffff; - data[2915]=(char)0xffff; - data[2916]=(char)0xffff; - data[2917]=(char)0xffff; - data[2918]=(char)0xffff; - data[2919]=(char)0xffff; - data[2920]=(char)0xffff; - data[2921]=(char)0xffff; - data[2922]=(char)0xffff; - data[2923]=(char)0xffff; - data[2924]=(char)0xffff; - data[2925]=(char)0xffff; - data[2926]=(char)0xffff; - data[2927]=(char)0xffff; - data[2928]=(char)0xffff; - data[2929]=(char)0xffff; - data[2930]=(char)0xffff; - data[2931]=(char)0xffff; - data[2932]=(char)0xffff; - data[2933]=(char)0xffff; - data[2934]=(char)0xffff; - data[2935]=(char)0xffff; - data[2936]=(char)0xffff; - data[2937]=(char)0xffff; - data[2938]=(char)0xffff; - data[2939]=(char)0xffff; - data[2940]=(char)0xffff; - data[2941]=(char)0xffff; - data[2942]=(char)0xffff; - data[2943]=(char)0xffff; - data[2944]=(char)0xffff; - data[2945]=(char)0xffff; - data[2946]=(char)0xffff; - data[2947]=(char)0xffff; - data[2948]=(char)0xffff; - data[2949]=(char)0xffff; - data[2950]=(char)0xffff; - data[2951]=(char)0xffff; - data[2952]=(char)0xffff; - data[2953]=(char)0xffff; - data[2954]=(char)0xffff; - data[2955]=(char)0xffff; - data[2956]=(char)0xffff; - data[2957]=(char)0xffff; - data[2958]=(char)0xffff; - data[2959]=(char)0xffff; - data[2960]=(char)0xffff; - data[2961]=(char)0xffff; - data[2962]=(char)0xffff; - data[2963]=(char)0xffff; - data[2964]=(char)0xffff; - data[2965]=(char)0xffff; - data[2966]=(char)0xffff; - data[2967]=(char)0xffff; - data[2968]=(char)0xffff; - data[2969]=(char)0xffff; - data[2970]=(char)0xffff; - data[2971]=(char)0xffff; - data[2972]=(char)0xffff; - data[2973]=(char)0xffff; - data[2974]=(char)0xffff; - data[2975]=(char)0xffff; - data[2976]=(char)0xffff; - data[2977]=(char)0xffff; - data[2978]=(char)0xffff; - data[2979]=(char)0xffff; - data[2980]=(char)0xffff; - data[2981]=(char)0xffff; - data[2982]=(char)0xffff; - data[2983]=(char)0xffff; - data[2984]=(char)0xffff; - data[2985]=(char)0xffff; - data[2986]=(char)0xffff; - data[2987]=(char)0xffff; - data[2988]=(char)0xffff; - data[2989]=(char)0xffff; - data[2990]=(char)0xffff; - data[2991]=(char)0xffff; - data[2992]=(char)0xffff; - data[2993]=(char)0xffff; - data[2994]=(char)0xffff; - data[2995]=(char)0xffff; - data[2996]=(char)0xffff; - data[2997]=(char)0xffff; - data[2998]=(char)0xffff; - data[2999]=(char)0xffff; - data[3000]=(char)0xffff; - data[3001]=(char)0xffff; - data[3002]=(char)0xffff; - data[3003]=(char)0xffff; - data[3004]=(char)0xffff; - data[3005]=(char)0xffff; - data[3006]=(char)0xffff; - data[3007]=(char)0xffff; - data[3008]=(char)0xffff; - data[3009]=(char)0xffff; - data[3010]=(char)0xffff; - data[3011]=(char)0xffff; - data[3012]=(char)0xffff; - data[3013]=(char)0xffff; - data[3014]=(char)0xffff; - data[3015]=(char)0xffff; - data[3016]=(char)0xffff; - data[3017]=(char)0xffff; - data[3018]=(char)0xffff; - data[3019]=(char)0xffff; - data[3020]=(char)0xffff; - data[3021]=(char)0xffff; - data[3022]=(char)0xffff; - data[3023]=(char)0xffff; - data[3024]=(char)0xffff; - data[3025]=(char)0xffff; - data[3026]=(char)0xffff; - data[3027]=(char)0xffff; - data[3028]=(char)0xffff; - data[3029]=(char)0xffff; - data[3030]=(char)0xffff; - data[3031]=(char)0xffff; - data[3032]=(char)0xffff; - data[3033]=(char)0xffff; - data[3034]=(char)0xffff; - data[3035]=(char)0xffff; - data[3036]=(char)0xffff; - data[3037]=(char)0xffff; - data[3038]=(char)0xffff; - data[3039]=(char)0xffff; - data[3040]=(char)0xffff; - data[3041]=(char)0xffff; - data[3042]=(char)0xffff; - data[3043]=(char)0xffff; - data[3044]=(char)0xffff; - data[3045]=(char)0xffff; - data[3046]=(char)0xffff; - data[3047]=(char)0xffff; - data[3048]=(char)0xffff; - data[3049]=(char)0xffff; - data[3050]=(char)0xffff; - data[3051]=(char)0xffff; - data[3052]=(char)0xffff; - data[3053]=(char)0xffff; - data[3054]=(char)0xffff; - data[3055]=(char)0xffff; - data[3056]=(char)0xffff; - data[3057]=(char)0xffff; - data[3058]=(char)0xffff; - data[3059]=(char)0xffff; - data[3060]=(char)0xffff; - data[3061]=(char)0xffff; - data[3062]=(char)0xffff; - data[3063]=(char)0xffff; - data[3064]=(char)0xffff; - data[3065]=(char)0xffff; - data[3066]=(char)0xffff; - data[3067]=(char)0xffff; - data[3068]=(char)0xffff; - data[3069]=(char)0xffff; - data[3070]=(char)0xffff; - data[3071]=(char)0xffff; - data[3072]=(char)0xffff; - data[3073]=(char)0xffff; - data[3074]=(char)0xffff; - data[3075]=(char)0xffff; - data[3076]=(char)0xffff; - data[3077]=(char)0xffff; - data[3078]=(char)0xffff; - data[3079]=(char)0xffff; - data[3080]=(char)0xffff; - data[3081]=(char)0xffff; - data[3082]=(char)0xffff; - data[3083]=(char)0xffff; - data[3084]=(char)0xffff; - data[3085]=(char)0xffff; - data[3086]=(char)0xffff; - data[3087]=(char)0xffff; - data[3088]=(char)0xffff; - data[3089]=(char)0xffff; - data[3090]=(char)0xffff; - data[3091]=(char)0xffff; - data[3092]=(char)0xffff; - data[3093]=(char)0xffff; - data[3094]=(char)0xffff; - data[3095]=(char)0xffff; - data[3096]=(char)0xffff; - data[3097]=(char)0xffff; - data[3098]=(char)0xffff; - data[3099]=(char)0xffff; - data[3100]=(char)0xffff; - data[3101]=(char)0xffff; - data[3102]=(char)0xffff; - data[3103]=(char)0xffff; - data[3104]=(char)0xffff; - data[3105]=(char)0xffff; - data[3106]=(char)0xffff; - data[3107]=(char)0xffff; - data[3108]=(char)0xffff; - data[3109]=(char)0xffff; - data[3110]=(char)0xffff; - data[3111]=(char)0xffff; - data[3112]=(char)0xffff; - data[3113]=(char)0xffff; - data[3114]=(char)0xffff; - data[3115]=(char)0xffff; - data[3116]=(char)0xffff; - data[3117]=(char)0xffff; - data[3118]=(char)0xffff; - data[3119]=(char)0xffff; - data[3120]=(char)0xffff; - data[3121]=(char)0xffff; - data[3122]=(char)0xffff; - data[3123]=(char)0xffff; - data[3124]=(char)0xffff; - data[3125]=(char)0xffff; - data[3126]=(char)0xffff; - data[3127]=(char)0xffff; - data[3128]=(char)0xffff; - data[3129]=(char)0xffff; - data[3130]=(char)0xffff; - data[3131]=(char)0xffff; - data[3132]=(char)0xffff; - data[3133]=(char)0xffff; - data[3134]=(char)0xffff; - data[3135]=(char)0xffff; - data[3136]=(char)0xffff; - data[3137]=(char)0xffff; - data[3138]=(char)0xffff; - data[3139]=(char)0xffff; - data[3140]=(char)0xffff; - data[3141]=(char)0xffff; - data[3142]=(char)0xffff; - data[3143]=(char)0xffff; - data[3144]=(char)0xffff; - data[3145]=(char)0xffff; - data[3146]=(char)0xffff; - data[3147]=(char)0xffff; - data[3148]=(char)0xffff; - data[3149]=(char)0xffff; - data[3150]=(char)0xffff; - data[3151]=(char)0xffff; - data[3152]=(char)0xffff; - data[3153]=(char)0xffff; - data[3154]=(char)0xffff; - data[3155]=(char)0xffff; - data[3156]=(char)0xffff; - data[3157]=(char)0xffff; - data[3158]=(char)0xffff; - data[3159]=(char)0xffff; - data[3160]=(char)0xffff; - data[3161]=(char)0xffff; - data[3162]=(char)0xffff; - data[3163]=(char)0xffff; - data[3164]=(char)0xffff; - data[3165]=(char)0xffff; - data[3166]=(char)0xffff; - data[3167]=(char)0xffff; - data[3168]=(char)0xffff; - data[3169]=(char)0xffff; - data[3170]=(char)0xffff; - data[3171]=(char)0xffff; - data[3172]=(char)0xffff; - data[3173]=(char)0xffff; - data[3174]=(char)0xffff; - data[3175]=(char)0xffff; - data[3176]=(char)0xffff; - data[3177]=(char)0xffff; - data[3178]=(char)0xffff; - data[3179]=(char)0xffff; - data[3180]=(char)0xffff; - data[3181]=(char)0xffff; - data[3182]=(char)0xffff; - data[3183]=(char)0xffff; - data[3184]=(char)0xffff; - data[3185]=(char)0xffff; - data[3186]=(char)0xffff; - data[3187]=(char)0xffff; - data[3188]=(char)0xffff; - data[3189]=(char)0xffff; - data[3190]=(char)0xffff; - data[3191]=(char)0xffff; - data[3192]=(char)0xffff; - data[3193]=(char)0xffff; - data[3194]=(char)0xffff; - data[3195]=(char)0xffff; - data[3196]=(char)0xffff; - data[3197]=(char)0xffff; - data[3198]=(char)0xffff; - data[3199]=(char)0xffff; - data[3200]=(char)0xffff; - data[3201]=(char)0xffff; - data[3202]=(char)0xffff; - data[3203]=(char)0xffff; - data[3204]=(char)0xffff; - data[3205]=(char)0xffff; - data[3206]=(char)0xffff; - data[3207]=(char)0xffff; - data[3208]=(char)0xffff; - data[3209]=(char)0xffff; - data[3210]=(char)0xffff; - data[3211]=(char)0xffff; - data[3212]=(char)0xffff; - data[3213]=(char)0xffff; - data[3214]=(char)0xffff; - data[3215]=(char)0xffff; - data[3216]=(char)0xffff; - data[3217]=(char)0xffff; - data[3218]=(char)0xffff; - data[3219]=(char)0xffff; - data[3220]=(char)0xffff; - data[3221]=(char)0xffff; - data[3222]=(char)0xffff; - data[3223]=(char)0xffff; - data[3224]=(char)0xffff; - data[3225]=(char)0xffff; - data[3226]=(char)0xffff; - data[3227]=(char)0xffff; - data[3228]=(char)0xffff; - data[3229]=(char)0xffff; - data[3230]=(char)0xffff; - data[3231]=(char)0xffff; - data[3232]=(char)0xffff; - data[3233]=(char)0xffff; - data[3234]=(char)0xffff; - data[3235]=(char)0xffff; - data[3236]=(char)0xffff; - data[3237]=(char)0xffff; - data[3238]=(char)0xffff; - data[3239]=(char)0xffff; - data[3240]=(char)0xffff; - data[3241]=(char)0xffff; - data[3242]=(char)0xffff; - data[3243]=(char)0xffff; - data[3244]=(char)0xffff; - data[3245]=(char)0xffff; - data[3246]=(char)0xffff; - data[3247]=(char)0xffff; - data[3248]=(char)0xffff; - data[3249]=(char)0xffff; - data[3250]=(char)0xffff; - data[3251]=(char)0xffff; - data[3252]=(char)0xffff; - data[3253]=(char)0xffff; - data[3254]=(char)0xffff; - data[3255]=(char)0xffff; - data[3256]=(char)0xffff; - data[3257]=(char)0xffff; - data[3258]=(char)0xffff; - data[3259]=(char)0xffff; - data[3260]=(char)0xffff; - data[3261]=(char)0xffff; - data[3262]=(char)0xffff; - data[3263]=(char)0xffff; - data[3264]=(char)0xffff; - data[3265]=(char)0xffff; - data[3266]=(char)0xffff; - data[3267]=(char)0xffff; - data[3268]=(char)0xffff; - data[3269]=(char)0xffff; - data[3270]=(char)0xffff; - data[3271]=(char)0xffff; - data[3272]=(char)0xffff; - data[3273]=(char)0xffff; - data[3274]=(char)0xffff; - data[3275]=(char)0xffff; - data[3276]=(char)0xffff; - data[3277]=(char)0xffff; - data[3278]=(char)0xffff; - data[3279]=(char)0xffff; - data[3280]=(char)0xffff; - data[3281]=(char)0xffff; - data[3282]=(char)0xffff; - data[3283]=(char)0xffff; - data[3284]=(char)0xffff; - data[3285]=(char)0xffff; - data[3286]=(char)0xffff; - data[3287]=(char)0xffff; - data[3288]=(char)0xffff; - data[3289]=(char)0xffff; - data[3290]=(char)0xffff; - data[3291]=(char)0xffff; - data[3292]=(char)0xffff; - data[3293]=(char)0xffff; - data[3294]=(char)0xffff; - data[3295]=(char)0xffff; - data[3296]=(char)0xffff; - data[3297]=(char)0xffff; - data[3298]=(char)0xffff; - data[3299]=(char)0xffff; - data[3300]=(char)0xffff; - data[3301]=(char)0xffff; - data[3302]=(char)0xffff; - data[3303]=(char)0xffff; - data[3304]=(char)0xffff; - data[3305]=(char)0xffff; - data[3306]=(char)0xffff; - data[3307]=(char)0xffff; - data[3308]=(char)0xffff; - data[3309]=(char)0xffff; - data[3310]=(char)0xffff; - data[3311]=(char)0xffff; - data[3312]=(char)0xffff; - data[3313]=(char)0xffff; - data[3314]=(char)0xffff; - data[3315]=(char)0xffff; - data[3316]=(char)0xffff; - data[3317]=(char)0xffff; - data[3318]=(char)0xffff; - data[3319]=(char)0xffff; - data[3320]=(char)0xffff; - data[3321]=(char)0xffff; - data[3322]=(char)0xffff; - data[3323]=(char)0xffff; - data[3324]=(char)0xffff; - data[3325]=(char)0xffff; - data[3326]=(char)0xffff; - data[3327]=(char)0xffff; - data[3328]=(char)0xffff; - data[3329]=(char)0xffff; - data[3330]=(char)0xffff; - data[3331]=(char)0xffff; - data[3332]=(char)0xffff; - data[3333]=(char)0xffff; - data[3334]=(char)0xffff; - data[3335]=(char)0xffff; - data[3336]=(char)0xffff; - data[3337]=(char)0xffff; - data[3338]=(char)0xffff; - data[3339]=(char)0xffff; - data[3340]=(char)0xffff; - data[3341]=(char)0xffff; - data[3342]=(char)0xffff; - data[3343]=(char)0xffff; - data[3344]=(char)0xffff; - data[3345]=(char)0xffff; - data[3346]=(char)0xffff; - data[3347]=(char)0xffff; - data[3348]=(char)0xffff; - data[3349]=(char)0xffff; - data[3350]=(char)0xffff; - data[3351]=(char)0xffff; - data[3352]=(char)0xffff; - data[3353]=(char)0xffff; - data[3354]=(char)0xffff; - data[3355]=(char)0xffff; - data[3356]=(char)0xffff; - data[3357]=(char)0xffff; - data[3358]=(char)0xffff; - data[3359]=(char)0xffff; - data[3360]=(char)0xffff; - data[3361]=(char)0xffff; - data[3362]=(char)0xffff; - data[3363]=(char)0xffff; - data[3364]=(char)0xffff; - data[3365]=(char)0xffff; - data[3366]=(char)0xffff; - data[3367]=(char)0xffff; - data[3368]=(char)0xffff; - data[3369]=(char)0xffff; - data[3370]=(char)0xffff; - data[3371]=(char)0xffff; - data[3372]=(char)0xffff; - data[3373]=(char)0xffff; - data[3374]=(char)0xffff; - data[3375]=(char)0xffff; - data[3376]=(char)0xffff; - data[3377]=(char)0xffff; - data[3378]=(char)0xffff; - data[3379]=(char)0xffff; - data[3380]=(char)0xffff; - data[3381]=(char)0xffff; - data[3382]=(char)0xffff; - data[3383]=(char)0xffff; - data[3384]=(char)0xffff; - data[3385]=(char)0xffff; - data[3386]=(char)0xffff; - data[3387]=(char)0xffff; - data[3388]=(char)0xffff; - data[3389]=(char)0xffff; - data[3390]=(char)0xffff; - data[3391]=(char)0xffff; - data[3392]=(char)0xffff; - data[3393]=(char)0xffff; - data[3394]=(char)0xffff; - data[3395]=(char)0xffff; - data[3396]=(char)0xffff; - data[3397]=(char)0xffff; - data[3398]=(char)0xffff; - data[3399]=(char)0xffff; - data[3400]=(char)0xffff; - data[3401]=(char)0xffff; - data[3402]=(char)0xffff; - data[3403]=(char)0xffff; - data[3404]=(char)0xffff; - data[3405]=(char)0xffff; - data[3406]=(char)0xffff; - data[3407]=(char)0xffff; - data[3408]=(char)0xffff; - data[3409]=(char)0xffff; - data[3410]=(char)0xffff; - data[3411]=(char)0xffff; - data[3412]=(char)0xffff; - data[3413]=(char)0xffff; - data[3414]=(char)0xffff; - data[3415]=(char)0xffff; - data[3416]=(char)0xffff; - data[3417]=(char)0xffff; - data[3418]=(char)0xffff; - data[3419]=(char)0xffff; - data[3420]=(char)0xffff; - data[3421]=(char)0xffff; - data[3422]=(char)0xffff; - data[3423]=(char)0xffff; - data[3424]=(char)0xffff; - data[3425]=(char)0xffff; - data[3426]=(char)0xffff; - data[3427]=(char)0xffff; - data[3428]=(char)0xffff; - data[3429]=(char)0xffff; - data[3430]=(char)0xffff; - data[3431]=(char)0xffff; - data[3432]=(char)0xffff; - data[3433]=(char)0xffff; - data[3434]=(char)0xffff; - data[3435]=(char)0xffff; - data[3436]=(char)0xffff; - data[3437]=(char)0xffff; - data[3438]=(char)0xffff; - data[3439]=(char)0xffff; - data[3440]=(char)0xffff; - data[3441]=(char)0xffff; - data[3442]=(char)0xffff; - data[3443]=(char)0xffff; - data[3444]=(char)0xffff; - data[3445]=(char)0xffff; - data[3446]=(char)0xffff; - data[3447]=(char)0xffff; - data[3448]=(char)0xffff; - data[3449]=(char)0xffff; - data[3450]=(char)0x000f; - data[3984]=(char)0xffff; - data[3985]=(char)0xffff; - data[3986]=(char)0xffff; - data[3987]=(char)0xffff; - data[3988]=(char)0xffff; - data[3989]=(char)0xffff; - data[3990]=(char)0xffff; - data[3991]=(char)0xffff; - data[3992]=(char)0xffff; - data[3993]=(char)0xffff; - data[3994]=(char)0xffff; - data[3995]=(char)0xffff; - data[3996]=(char)0xffff; - data[3997]=(char)0xffff; - data[3998]=(char)0xffff; - data[3999]=(char)0xffff; - data[4000]=(char)0xffff; - data[4001]=(char)0xffff; - data[4002]=(char)0x3fff; - data[4016]=(char)0x007f; - data[4017]=(char)0x80f8; - data[4018]=(char)0xfdff; - data[4019]=(char)0x5f7f; - data[4020]=(char)0xffdb; - data[4021]=(char)0xffff; - data[4022]=(char)0xffff; - data[4023]=(char)0xffff; - data[4024]=(char)0xffff; - data[4025]=(char)0xffff; - data[4026]=(char)0xffff; - data[4027]=(char)0x0003; - data[4029]=(char)0xfff8; - data[4030]=(char)0xffff; - data[4031]=(char)0xffff; - data[4032]=(char)0xffff; - data[4033]=(char)0xffff; - data[4034]=(char)0xffff; - data[4035]=(char)0xffff; - data[4036]=(char)0xffff; - data[4037]=(char)0xffff; - data[4038]=(char)0xffff; - data[4039]=(char)0xffff; - data[4040]=(char)0xffff; - data[4041]=(char)0xffff; - data[4042]=(char)0xffff; - data[4043]=(char)0xffff; - data[4044]=(char)0xffff; - data[4045]=(char)0xffff; - data[4046]=(char)0xffff; - data[4047]=(char)0xffff; - data[4048]=(char)0xffff; - data[4049]=(char)0xffff; - data[4050]=(char)0xffff; - data[4051]=(char)0x3fff; - data[4053]=(char)0xffff; - data[4054]=(char)0xffff; - data[4055]=(char)0xffff; - data[4056]=(char)0xffff; - data[4057]=(char)0xfffc; - data[4058]=(char)0xffff; - data[4059]=(char)0xffff; - data[4060]=(char)0x00ff; - data[4063]=(char)0x0fff; - data[4071]=(char)0xffd7; - data[4072]=(char)0xffff; - data[4073]=(char)0xffff; - data[4074]=(char)0xffff; - data[4075]=(char)0xffff; - data[4076]=(char)0xffff; - data[4077]=(char)0xffff; - data[4078]=(char)0xffff; - data[4079]=(char)0x1fff; - data[4082]=(char)0xfffe; - data[4083]=(char)0x07ff; - data[4084]=(char)0xfffe; - data[4085]=(char)0x07ff; - data[4086]=(char)0xffc0; - data[4087]=(char)0xffff; - data[4088]=(char)0xffff; - data[4089]=(char)0xffff; - data[4090]=(char)0xffff; - data[4091]=(char)0x7fff; - data[4092]=(char)0xfcfc; - data[4093]=(char)0x1cfc; - data[4100]=(char)0xfffe; - data[4101]=(char)0x07ff; - data[4102]=(char)0xfffe; - data[4103]=(char)0x07ff; - data[4106]=(char)0x0400; - data[4107]=(char)0x0420; - data[4108]=(char)0xffff; - data[4109]=(char)0xff7f; - data[4110]=(char)0xffff; - data[4111]=(char)0xff7f; - data[4112]=(char)0xffff; - data[4113]=(char)0xffff; - data[4114]=(char)0xffff; - data[4115]=(char)0xffff; - data[4116]=(char)0xffff; - data[4117]=(char)0xffff; - data[4118]=(char)0xffff; - data[4119]=(char)0xffff; - data[4120]=(char)0xffff; - data[4121]=(char)0xffff; - data[4122]=(char)0xffff; - data[4123]=(char)0xffff; - data[4124]=(char)0xffff; - data[4125]=(char)0xffff; - data[4126]=(char)0xffff; - data[4127]=(char)0xfc3f; - data[4128]=(char)0xffff; - data[4129]=(char)0x00ff; - data[4133]=(char)0xffff; - data[4134]=(char)0xffff; - data[4135]=(char)0xffff; - data[4136]=(char)0xffff; - data[4137]=(char)0xffff; - data[4138]=(char)0x01ff; - data[4139]=(char)0xf9ff; - data[4140]=(char)0x0003; - data[4141]=(char)0x0003; - data[4142]=(char)0x001f; - data[4151]=(char)0x0400; - data[4152]=(char)0xd740; - data[4153]=(char)0xffff; - data[4154]=(char)0xfffb; - data[4155]=(char)0xffff; - data[4156]=(char)0x7fff; - data[4157]=(char)0x547f; - data[4158]=(char)0x00fd; + data[4] = (char) 0xfffe; + data[5] = (char) 0x07ff; + data[6] = (char) 0xfffe; + data[7] = (char) 0x07ff; + data[10] = (char) 0x0400; + data[11] = (char) 0x0420; + data[12] = (char) 0xffff; + data[13] = (char) 0xff7f; + data[14] = (char) 0xffff; + data[15] = (char) 0xff7f; + data[16] = (char) 0xffff; + data[17] = (char) 0xffff; + data[18] = (char) 0xffff; + data[19] = (char) 0xffff; + data[20] = (char) 0xffff; + data[21] = (char) 0xffff; + data[22] = (char) 0xffff; + data[23] = (char) 0xffff; + data[24] = (char) 0xffff; + data[25] = (char) 0xffff; + data[26] = (char) 0xffff; + data[27] = (char) 0xffff; + data[28] = (char) 0xffff; + data[29] = (char) 0xffff; + data[30] = (char) 0xffff; + data[31] = (char) 0xfc3f; + data[32] = (char) 0xffff; + data[33] = (char) 0x00ff; + data[37] = (char) 0xffff; + data[38] = (char) 0xffff; + data[39] = (char) 0xffff; + data[40] = (char) 0xffff; + data[41] = (char) 0xffff; + data[42] = (char) 0x01ff; + data[43] = (char) 0xf9ff; + data[44] = (char) 0x0003; + data[45] = (char) 0x0003; + data[46] = (char) 0x001f; + data[55] = (char) 0x0400; + data[56] = (char) 0xd740; + data[57] = (char) 0xffff; + data[58] = (char) 0xfffb; + data[59] = (char) 0xffff; + data[60] = (char) 0x7fff; + data[61] = (char) 0x547f; + data[62] = (char) 0xfffd; + data[63] = (char) 0x000f; + data[64] = (char) 0xdffe; + data[65] = (char) 0xffff; + data[66] = (char) 0xffff; + data[67] = (char) 0xffff; + data[68] = (char) 0xffff; + data[69] = (char) 0xdffe; + data[70] = (char) 0xffff; + data[71] = (char) 0xffff; + data[72] = (char) 0x0003; + data[73] = (char) 0xffff; + data[74] = (char) 0xffff; + data[75] = (char) 0xffff; + data[76] = (char) 0x199f; + data[77] = (char) 0xffff; + data[78] = (char) 0xcfff; + data[79] = (char) 0x033f; + data[83] = (char) 0xfffe; + data[84] = (char) 0xffff; + data[85] = (char) 0x027f; + data[86] = (char) 0xfffe; + data[87] = (char) 0xffff; + data[88] = (char) 0x00ff; + data[93] = (char) 0xffff; + data[94] = (char) 0x07ff; + data[95] = (char) 0x0007; + data[98] = (char) 0xfffe; + data[99] = (char) 0x07ff; + data[100] = (char) 0x07ff; + data[103] = (char) 0xfffe; + data[104] = (char) 0xffff; + data[105] = (char) 0xffff; + data[106] = (char) 0xffff; + data[107] = (char) 0x7cff; + data[108] = (char) 0x7fff; + data[109] = (char) 0x002f; + data[110] = (char) 0x0060; + data[144] = (char) 0xffe0; + data[145] = (char) 0xffff; + data[146] = (char) 0xffff; + data[147] = (char) 0x23ff; + data[149] = (char) 0xff00; + data[150] = (char) 0x0003; + data[152] = (char) 0x9fe0; + data[153] = (char) 0xfff9; + data[154] = (char) 0xfdff; + data[155] = (char) 0x03c5; + data[157] = (char) 0xb000; + data[158] = (char) 0x0003; + data[159] = (char) 0x0003; + data[160] = (char) 0x87e0; + data[161] = (char) 0xfff9; + data[162] = (char) 0xfdff; + data[163] = (char) 0x036d; + data[165] = (char) 0x5e00; + data[167] = (char) 0x001c; + data[168] = (char) 0xafe0; + data[169] = (char) 0xfffb; + data[170] = (char) 0xfdff; + data[171] = (char) 0x23ed; + data[174] = (char) 0x0001; + data[176] = (char) 0x9fe0; + data[177] = (char) 0xfff9; + data[178] = (char) 0xfdff; + data[179] = (char) 0x23cd; + data[181] = (char) 0xb000; + data[182] = (char) 0x0003; + data[184] = (char) 0xc7e0; + data[185] = (char) 0xd63d; + data[186] = (char) 0xc718; + data[187] = (char) 0x03bf; + data[192] = (char) 0xdfe0; + data[193] = (char) 0xfffd; + data[194] = (char) 0xfdff; + data[195] = (char) 0x03ef; + data[198] = (char) 0x0003; + data[200] = (char) 0xdfe0; + data[201] = (char) 0xfffd; + data[202] = (char) 0xfdff; + data[203] = (char) 0x03ef; + data[205] = (char) 0x4000; + data[206] = (char) 0x0003; + data[208] = (char) 0xdfe0; + data[209] = (char) 0xfffd; + data[210] = (char) 0xfdff; + data[211] = (char) 0x03ff; + data[214] = (char) 0x0003; + data[224] = (char) 0xfffe; + data[225] = (char) 0xffff; + data[226] = (char) 0x7fff; + data[227] = (char) 0x000d; + data[228] = (char) 0x007f; + data[232] = (char) 0x2596; + data[233] = (char) 0xfef0; + data[234] = (char) 0x6cae; + data[235] = (char) 0x200d; + data[236] = (char) 0x005f; + data[237] = (char) 0x3000; + data[244] = (char) 0xfeff; + data[245] = (char) 0xffff; + data[246] = (char) 0x03ff; + data[266] = (char) 0xffff; + data[267] = (char) 0xffff; + data[268] = (char) 0x003f; + data[269] = (char) 0xffff; + data[270] = (char) 0xffff; + data[271] = (char) 0x007f; + data[272] = (char) 0xffff; + data[273] = (char) 0xffff; + data[274] = (char) 0xffff; + data[275] = (char) 0xffff; + data[276] = (char) 0xffff; + data[277] = (char) 0x83ff; + data[278] = (char) 0xffff; + data[279] = (char) 0xffff; + data[280] = (char) 0xffff; + data[281] = (char) 0xffff; + data[282] = (char) 0xff07; + data[283] = (char) 0xffff; + data[284] = (char) 0xffff; + data[285] = (char) 0xffff; + data[286] = (char) 0xffff; + data[287] = (char) 0x03ff; + data[480] = (char) 0xffff; + data[481] = (char) 0xffff; + data[482] = (char) 0xffff; + data[483] = (char) 0xffff; + data[484] = (char) 0xffff; + data[485] = (char) 0xffff; + data[486] = (char) 0xffff; + data[487] = (char) 0xffff; + data[488] = (char) 0xffff; + data[489] = (char) 0x0fff; + data[490] = (char) 0xffff; + data[491] = (char) 0xffff; + data[492] = (char) 0xffff; + data[493] = (char) 0xffff; + data[494] = (char) 0xffff; + data[495] = (char) 0x03ff; + data[496] = (char) 0xffff; + data[497] = (char) 0x3f3f; + data[498] = (char) 0xffff; + data[499] = (char) 0xffff; + data[500] = (char) 0x3f3f; + data[501] = (char) 0xaaff; + data[502] = (char) 0xffff; + data[503] = (char) 0x3fff; + data[504] = (char) 0xffff; + data[505] = (char) 0xffff; + data[506] = (char) 0xffff; + data[507] = (char) 0x5fdf; + data[508] = (char) 0x1fdc; + data[509] = (char) 0x0fcf; + data[510] = (char) 0x1fff; + data[511] = (char) 0x1fdc; + data[519] = (char) 0x8000; + data[528] = (char) 0xfc84; + data[529] = (char) 0x3f2f; + data[530] = (char) 0xfd50; + data[531] = (char) 0x01fb; + data[768] = (char) 0x0020; + data[771] = (char) 0x003e; + data[772] = (char) 0xfffe; + data[773] = (char) 0xffff; + data[774] = (char) 0xffff; + data[775] = (char) 0xffff; + data[776] = (char) 0xffff; + data[777] = (char) 0x781f; + data[778] = (char) 0xfffe; + data[779] = (char) 0xffff; + data[780] = (char) 0xffff; + data[781] = (char) 0xffff; + data[782] = (char) 0xffff; + data[783] = (char) 0x77ff; + data[784] = (char) 0xffe0; + data[785] = (char) 0xffff; + data[786] = (char) 0x1fff; + data[787] = (char) 0xfffe; + data[788] = (char) 0xffff; + data[789] = (char) 0xffff; + data[790] = (char) 0xffff; + data[791] = (char) 0xffff; + data[792] = (char) 0x7fff; + data[1248] = (char) 0xffff; + data[1249] = (char) 0xffff; + data[1250] = (char) 0xffff; + data[1251] = (char) 0xffff; + data[1252] = (char) 0xffff; + data[1253] = (char) 0xffff; + data[1254] = (char) 0xffff; + data[1255] = (char) 0xffff; + data[1256] = (char) 0xffff; + data[1257] = (char) 0xffff; + data[1258] = (char) 0xffff; + data[1259] = (char) 0xffff; + data[1260] = (char) 0xffff; + data[1261] = (char) 0xffff; + data[1262] = (char) 0xffff; + data[1263] = (char) 0xffff; + data[1264] = (char) 0xffff; + data[1265] = (char) 0xffff; + data[1266] = (char) 0xffff; + data[1267] = (char) 0xffff; + data[1268] = (char) 0xffff; + data[1269] = (char) 0xffff; + data[1270] = (char) 0xffff; + data[1271] = (char) 0xffff; + data[1272] = (char) 0xffff; + data[1273] = (char) 0xffff; + data[1274] = (char) 0xffff; + data[1275] = (char) 0xffff; + data[1276] = (char) 0xffff; + data[1277] = (char) 0xffff; + data[1278] = (char) 0xffff; + data[1279] = (char) 0xffff; + data[1280] = (char) 0xffff; + data[1281] = (char) 0xffff; + data[1282] = (char) 0xffff; + data[1283] = (char) 0xffff; + data[1284] = (char) 0xffff; + data[1285] = (char) 0xffff; + data[1286] = (char) 0xffff; + data[1287] = (char) 0xffff; + data[1288] = (char) 0xffff; + data[1289] = (char) 0xffff; + data[1290] = (char) 0xffff; + data[1291] = (char) 0xffff; + data[1292] = (char) 0xffff; + data[1293] = (char) 0xffff; + data[1294] = (char) 0xffff; + data[1295] = (char) 0xffff; + data[1296] = (char) 0xffff; + data[1297] = (char) 0xffff; + data[1298] = (char) 0xffff; + data[1299] = (char) 0xffff; + data[1300] = (char) 0xffff; + data[1301] = (char) 0xffff; + data[1302] = (char) 0xffff; + data[1303] = (char) 0xffff; + data[1304] = (char) 0xffff; + data[1305] = (char) 0xffff; + data[1306] = (char) 0xffff; + data[1307] = (char) 0xffff; + data[1308] = (char) 0xffff; + data[1309] = (char) 0xffff; + data[1310] = (char) 0xffff; + data[1311] = (char) 0xffff; + data[1312] = (char) 0xffff; + data[1313] = (char) 0xffff; + data[1314] = (char) 0xffff; + data[1315] = (char) 0xffff; + data[1316] = (char) 0xffff; + data[1317] = (char) 0xffff; + data[1318] = (char) 0xffff; + data[1319] = (char) 0xffff; + data[1320] = (char) 0xffff; + data[1321] = (char) 0xffff; + data[1322] = (char) 0xffff; + data[1323] = (char) 0xffff; + data[1324] = (char) 0xffff; + data[1325] = (char) 0xffff; + data[1326] = (char) 0xffff; + data[1327] = (char) 0xffff; + data[1328] = (char) 0xffff; + data[1329] = (char) 0xffff; + data[1330] = (char) 0xffff; + data[1331] = (char) 0xffff; + data[1332] = (char) 0xffff; + data[1333] = (char) 0xffff; + data[1334] = (char) 0xffff; + data[1335] = (char) 0xffff; + data[1336] = (char) 0xffff; + data[1337] = (char) 0xffff; + data[1338] = (char) 0xffff; + data[1339] = (char) 0xffff; + data[1340] = (char) 0xffff; + data[1341] = (char) 0xffff; + data[1342] = (char) 0xffff; + data[1343] = (char) 0xffff; + data[1344] = (char) 0xffff; + data[1345] = (char) 0xffff; + data[1346] = (char) 0xffff; + data[1347] = (char) 0xffff; + data[1348] = (char) 0xffff; + data[1349] = (char) 0xffff; + data[1350] = (char) 0xffff; + data[1351] = (char) 0xffff; + data[1352] = (char) 0xffff; + data[1353] = (char) 0xffff; + data[1354] = (char) 0xffff; + data[1355] = (char) 0xffff; + data[1356] = (char) 0xffff; + data[1357] = (char) 0xffff; + data[1358] = (char) 0xffff; + data[1359] = (char) 0xffff; + data[1360] = (char) 0xffff; + data[1361] = (char) 0xffff; + data[1362] = (char) 0xffff; + data[1363] = (char) 0xffff; + data[1364] = (char) 0xffff; + data[1365] = (char) 0xffff; + data[1366] = (char) 0xffff; + data[1367] = (char) 0xffff; + data[1368] = (char) 0xffff; + data[1369] = (char) 0xffff; + data[1370] = (char) 0xffff; + data[1371] = (char) 0xffff; + data[1372] = (char) 0xffff; + data[1373] = (char) 0xffff; + data[1374] = (char) 0xffff; + data[1375] = (char) 0xffff; + data[1376] = (char) 0xffff; + data[1377] = (char) 0xffff; + data[1378] = (char) 0xffff; + data[1379] = (char) 0xffff; + data[1380] = (char) 0xffff; + data[1381] = (char) 0xffff; + data[1382] = (char) 0xffff; + data[1383] = (char) 0xffff; + data[1384] = (char) 0xffff; + data[1385] = (char) 0xffff; + data[1386] = (char) 0xffff; + data[1387] = (char) 0xffff; + data[1388] = (char) 0xffff; + data[1389] = (char) 0xffff; + data[1390] = (char) 0xffff; + data[1391] = (char) 0xffff; + data[1392] = (char) 0xffff; + data[1393] = (char) 0xffff; + data[1394] = (char) 0xffff; + data[1395] = (char) 0xffff; + data[1396] = (char) 0xffff; + data[1397] = (char) 0xffff; + data[1398] = (char) 0xffff; + data[1399] = (char) 0xffff; + data[1400] = (char) 0xffff; + data[1401] = (char) 0xffff; + data[1402] = (char) 0xffff; + data[1403] = (char) 0xffff; + data[1404] = (char) 0xffff; + data[1405] = (char) 0xffff; + data[1406] = (char) 0xffff; + data[1407] = (char) 0xffff; + data[1408] = (char) 0xffff; + data[1409] = (char) 0xffff; + data[1410] = (char) 0xffff; + data[1411] = (char) 0xffff; + data[1412] = (char) 0xffff; + data[1413] = (char) 0xffff; + data[1414] = (char) 0xffff; + data[1415] = (char) 0xffff; + data[1416] = (char) 0xffff; + data[1417] = (char) 0xffff; + data[1418] = (char) 0xffff; + data[1419] = (char) 0xffff; + data[1420] = (char) 0xffff; + data[1421] = (char) 0xffff; + data[1422] = (char) 0xffff; + data[1423] = (char) 0xffff; + data[1424] = (char) 0xffff; + data[1425] = (char) 0xffff; + data[1426] = (char) 0xffff; + data[1427] = (char) 0xffff; + data[1428] = (char) 0xffff; + data[1429] = (char) 0xffff; + data[1430] = (char) 0xffff; + data[1431] = (char) 0xffff; + data[1432] = (char) 0xffff; + data[1433] = (char) 0xffff; + data[1434] = (char) 0xffff; + data[1435] = (char) 0xffff; + data[1436] = (char) 0xffff; + data[1437] = (char) 0xffff; + data[1438] = (char) 0xffff; + data[1439] = (char) 0xffff; + data[1440] = (char) 0xffff; + data[1441] = (char) 0xffff; + data[1442] = (char) 0xffff; + data[1443] = (char) 0xffff; + data[1444] = (char) 0xffff; + data[1445] = (char) 0xffff; + data[1446] = (char) 0xffff; + data[1447] = (char) 0xffff; + data[1448] = (char) 0xffff; + data[1449] = (char) 0xffff; + data[1450] = (char) 0xffff; + data[1451] = (char) 0xffff; + data[1452] = (char) 0xffff; + data[1453] = (char) 0xffff; + data[1454] = (char) 0xffff; + data[1455] = (char) 0xffff; + data[1456] = (char) 0xffff; + data[1457] = (char) 0xffff; + data[1458] = (char) 0xffff; + data[1459] = (char) 0xffff; + data[1460] = (char) 0xffff; + data[1461] = (char) 0xffff; + data[1462] = (char) 0xffff; + data[1463] = (char) 0xffff; + data[1464] = (char) 0xffff; + data[1465] = (char) 0xffff; + data[1466] = (char) 0xffff; + data[1467] = (char) 0xffff; + data[1468] = (char) 0xffff; + data[1469] = (char) 0xffff; + data[1470] = (char) 0xffff; + data[1471] = (char) 0xffff; + data[1472] = (char) 0xffff; + data[1473] = (char) 0xffff; + data[1474] = (char) 0xffff; + data[1475] = (char) 0xffff; + data[1476] = (char) 0xffff; + data[1477] = (char) 0xffff; + data[1478] = (char) 0xffff; + data[1479] = (char) 0xffff; + data[1480] = (char) 0xffff; + data[1481] = (char) 0xffff; + data[1482] = (char) 0xffff; + data[1483] = (char) 0xffff; + data[1484] = (char) 0xffff; + data[1485] = (char) 0xffff; + data[1486] = (char) 0xffff; + data[1487] = (char) 0xffff; + data[1488] = (char) 0xffff; + data[1489] = (char) 0xffff; + data[1490] = (char) 0xffff; + data[1491] = (char) 0xffff; + data[1492] = (char) 0xffff; + data[1493] = (char) 0xffff; + data[1494] = (char) 0xffff; + data[1495] = (char) 0xffff; + data[1496] = (char) 0xffff; + data[1497] = (char) 0xffff; + data[1498] = (char) 0xffff; + data[1499] = (char) 0xffff; + data[1500] = (char) 0xffff; + data[1501] = (char) 0xffff; + data[1502] = (char) 0xffff; + data[1503] = (char) 0xffff; + data[1504] = (char) 0xffff; + data[1505] = (char) 0xffff; + data[1506] = (char) 0xffff; + data[1507] = (char) 0xffff; + data[1508] = (char) 0xffff; + data[1509] = (char) 0xffff; + data[1510] = (char) 0xffff; + data[1511] = (char) 0xffff; + data[1512] = (char) 0xffff; + data[1513] = (char) 0xffff; + data[1514] = (char) 0xffff; + data[1515] = (char) 0xffff; + data[1516] = (char) 0xffff; + data[1517] = (char) 0xffff; + data[1518] = (char) 0xffff; + data[1519] = (char) 0xffff; + data[1520] = (char) 0xffff; + data[1521] = (char) 0xffff; + data[1522] = (char) 0xffff; + data[1523] = (char) 0xffff; + data[1524] = (char) 0xffff; + data[1525] = (char) 0xffff; + data[1526] = (char) 0xffff; + data[1527] = (char) 0xffff; + data[1528] = (char) 0xffff; + data[1529] = (char) 0xffff; + data[1530] = (char) 0xffff; + data[1531] = (char) 0xffff; + data[1532] = (char) 0xffff; + data[1533] = (char) 0xffff; + data[1534] = (char) 0xffff; + data[1535] = (char) 0xffff; + data[1536] = (char) 0xffff; + data[1537] = (char) 0xffff; + data[1538] = (char) 0xffff; + data[1539] = (char) 0xffff; + data[1540] = (char) 0xffff; + data[1541] = (char) 0xffff; + data[1542] = (char) 0xffff; + data[1543] = (char) 0xffff; + data[1544] = (char) 0xffff; + data[1545] = (char) 0xffff; + data[1546] = (char) 0xffff; + data[1547] = (char) 0xffff; + data[1548] = (char) 0xffff; + data[1549] = (char) 0xffff; + data[1550] = (char) 0xffff; + data[1551] = (char) 0xffff; + data[1552] = (char) 0xffff; + data[1553] = (char) 0xffff; + data[1554] = (char) 0xffff; + data[1555] = (char) 0xffff; + data[1556] = (char) 0xffff; + data[1557] = (char) 0xffff; + data[1558] = (char) 0xffff; + data[1559] = (char) 0xffff; + data[1560] = (char) 0xffff; + data[1561] = (char) 0xffff; + data[1562] = (char) 0xffff; + data[1563] = (char) 0xffff; + data[1564] = (char) 0xffff; + data[1565] = (char) 0xffff; + data[1566] = (char) 0xffff; + data[1567] = (char) 0xffff; + data[1568] = (char) 0xffff; + data[1569] = (char) 0xffff; + data[1570] = (char) 0xffff; + data[1571] = (char) 0xffff; + data[1572] = (char) 0xffff; + data[1573] = (char) 0xffff; + data[1574] = (char) 0xffff; + data[1575] = (char) 0xffff; + data[1576] = (char) 0xffff; + data[1577] = (char) 0xffff; + data[1578] = (char) 0xffff; + data[1579] = (char) 0xffff; + data[1580] = (char) 0xffff; + data[1581] = (char) 0xffff; + data[1582] = (char) 0xffff; + data[1583] = (char) 0xffff; + data[1584] = (char) 0xffff; + data[1585] = (char) 0xffff; + data[1586] = (char) 0xffff; + data[1587] = (char) 0xffff; + data[1588] = (char) 0xffff; + data[1589] = (char) 0xffff; + data[1590] = (char) 0xffff; + data[1591] = (char) 0xffff; + data[1592] = (char) 0xffff; + data[1593] = (char) 0xffff; + data[1594] = (char) 0xffff; + data[1595] = (char) 0xffff; + data[1596] = (char) 0xffff; + data[1597] = (char) 0xffff; + data[1598] = (char) 0xffff; + data[1599] = (char) 0xffff; + data[1600] = (char) 0xffff; + data[1601] = (char) 0xffff; + data[1602] = (char) 0xffff; + data[1603] = (char) 0xffff; + data[1604] = (char) 0xffff; + data[1605] = (char) 0xffff; + data[1606] = (char) 0xffff; + data[1607] = (char) 0xffff; + data[1608] = (char) 0xffff; + data[1609] = (char) 0xffff; + data[1610] = (char) 0xffff; + data[1611] = (char) 0xffff; + data[1612] = (char) 0xffff; + data[1613] = (char) 0xffff; + data[1614] = (char) 0xffff; + data[1615] = (char) 0xffff; + data[1616] = (char) 0xffff; + data[1617] = (char) 0xffff; + data[1618] = (char) 0xffff; + data[1619] = (char) 0xffff; + data[1620] = (char) 0xffff; + data[1621] = (char) 0xffff; + data[1622] = (char) 0xffff; + data[1623] = (char) 0xffff; + data[1624] = (char) 0xffff; + data[1625] = (char) 0xffff; + data[1626] = (char) 0xffff; + data[1627] = (char) 0xffff; + data[1628] = (char) 0xffff; + data[1629] = (char) 0xffff; + data[1630] = (char) 0xffff; + data[1631] = (char) 0xffff; + data[1632] = (char) 0xffff; + data[1633] = (char) 0xffff; + data[1634] = (char) 0xffff; + data[1635] = (char) 0xffff; + data[1636] = (char) 0xffff; + data[1637] = (char) 0xffff; + data[1638] = (char) 0xffff; + data[1639] = (char) 0xffff; + data[1640] = (char) 0xffff; + data[1641] = (char) 0xffff; + data[1642] = (char) 0xffff; + data[1643] = (char) 0xffff; + data[1644] = (char) 0xffff; + data[1645] = (char) 0xffff; + data[1646] = (char) 0xffff; + data[1647] = (char) 0xffff; + data[1648] = (char) 0xffff; + data[1649] = (char) 0xffff; + data[1650] = (char) 0xffff; + data[1651] = (char) 0xffff; + data[1652] = (char) 0xffff; + data[1653] = (char) 0xffff; + data[1654] = (char) 0xffff; + data[1655] = (char) 0xffff; + data[1656] = (char) 0xffff; + data[1657] = (char) 0xffff; + data[1658] = (char) 0xffff; + data[1659] = (char) 0xffff; + data[1660] = (char) 0xffff; + data[1661] = (char) 0xffff; + data[1662] = (char) 0xffff; + data[1663] = (char) 0xffff; + data[1664] = (char) 0xffff; + data[1665] = (char) 0xffff; + data[1666] = (char) 0xffff; + data[1667] = (char) 0xffff; + data[1668] = (char) 0xffff; + data[1669] = (char) 0xffff; + data[1670] = (char) 0xffff; + data[1671] = (char) 0xffff; + data[1672] = (char) 0xffff; + data[1673] = (char) 0xffff; + data[1674] = (char) 0xffff; + data[1675] = (char) 0xffff; + data[1676] = (char) 0xffff; + data[1677] = (char) 0xffff; + data[1678] = (char) 0xffff; + data[1679] = (char) 0xffff; + data[1680] = (char) 0xffff; + data[1681] = (char) 0xffff; + data[1682] = (char) 0xffff; + data[1683] = (char) 0xffff; + data[1684] = (char) 0xffff; + data[1685] = (char) 0xffff; + data[1686] = (char) 0xffff; + data[1687] = (char) 0xffff; + data[1688] = (char) 0xffff; + data[1689] = (char) 0xffff; + data[1690] = (char) 0xffff; + data[1691] = (char) 0xffff; + data[1692] = (char) 0xffff; + data[1693] = (char) 0xffff; + data[1694] = (char) 0xffff; + data[1695] = (char) 0xffff; + data[1696] = (char) 0xffff; + data[1697] = (char) 0xffff; + data[1698] = (char) 0xffff; + data[1699] = (char) 0xffff; + data[1700] = (char) 0xffff; + data[1701] = (char) 0xffff; + data[1702] = (char) 0xffff; + data[1703] = (char) 0xffff; + data[1704] = (char) 0xffff; + data[1705] = (char) 0xffff; + data[1706] = (char) 0xffff; + data[1707] = (char) 0xffff; + data[1708] = (char) 0xffff; + data[1709] = (char) 0xffff; + data[1710] = (char) 0xffff; + data[1711] = (char) 0xffff; + data[1712] = (char) 0xffff; + data[1713] = (char) 0xffff; + data[1714] = (char) 0xffff; + data[1715] = (char) 0xffff; + data[1716] = (char) 0xffff; + data[1717] = (char) 0xffff; + data[1718] = (char) 0xffff; + data[1719] = (char) 0xffff; + data[1720] = (char) 0xffff; + data[1721] = (char) 0xffff; + data[1722] = (char) 0xffff; + data[1723] = (char) 0xffff; + data[1724] = (char) 0xffff; + data[1725] = (char) 0xffff; + data[1726] = (char) 0xffff; + data[1727] = (char) 0xffff; + data[1728] = (char) 0xffff; + data[1729] = (char) 0xffff; + data[1730] = (char) 0xffff; + data[1731] = (char) 0xffff; + data[1732] = (char) 0xffff; + data[1733] = (char) 0xffff; + data[1734] = (char) 0xffff; + data[1735] = (char) 0xffff; + data[1736] = (char) 0xffff; + data[1737] = (char) 0xffff; + data[1738] = (char) 0xffff; + data[1739] = (char) 0xffff; + data[1740] = (char) 0xffff; + data[1741] = (char) 0xffff; + data[1742] = (char) 0xffff; + data[1743] = (char) 0xffff; + data[1744] = (char) 0xffff; + data[1745] = (char) 0xffff; + data[1746] = (char) 0xffff; + data[1747] = (char) 0xffff; + data[1748] = (char) 0xffff; + data[1749] = (char) 0xffff; + data[1750] = (char) 0xffff; + data[1751] = (char) 0xffff; + data[1752] = (char) 0xffff; + data[1753] = (char) 0xffff; + data[1754] = (char) 0xffff; + data[1755] = (char) 0xffff; + data[1756] = (char) 0xffff; + data[1757] = (char) 0xffff; + data[1758] = (char) 0xffff; + data[1759] = (char) 0xffff; + data[1760] = (char) 0xffff; + data[1761] = (char) 0xffff; + data[1762] = (char) 0xffff; + data[1763] = (char) 0xffff; + data[1764] = (char) 0xffff; + data[1765] = (char) 0xffff; + data[1766] = (char) 0xffff; + data[1767] = (char) 0xffff; + data[1768] = (char) 0xffff; + data[1769] = (char) 0xffff; + data[1770] = (char) 0xffff; + data[1771] = (char) 0xffff; + data[1772] = (char) 0xffff; + data[1773] = (char) 0xffff; + data[1774] = (char) 0xffff; + data[1775] = (char) 0xffff; + data[1776] = (char) 0xffff; + data[1777] = (char) 0xffff; + data[1778] = (char) 0xffff; + data[1779] = (char) 0xffff; + data[1780] = (char) 0xffff; + data[1781] = (char) 0xffff; + data[1782] = (char) 0xffff; + data[1783] = (char) 0xffff; + data[1784] = (char) 0xffff; + data[1785] = (char) 0xffff; + data[1786] = (char) 0xffff; + data[1787] = (char) 0xffff; + data[1788] = (char) 0xffff; + data[1789] = (char) 0xffff; + data[1790] = (char) 0xffff; + data[1791] = (char) 0xffff; + data[1792] = (char) 0xffff; + data[1793] = (char) 0xffff; + data[1794] = (char) 0xffff; + data[1795] = (char) 0xffff; + data[1796] = (char) 0xffff; + data[1797] = (char) 0xffff; + data[1798] = (char) 0xffff; + data[1799] = (char) 0xffff; + data[1800] = (char) 0xffff; + data[1801] = (char) 0xffff; + data[1802] = (char) 0xffff; + data[1803] = (char) 0xffff; + data[1804] = (char) 0xffff; + data[1805] = (char) 0xffff; + data[1806] = (char) 0xffff; + data[1807] = (char) 0xffff; + data[1808] = (char) 0xffff; + data[1809] = (char) 0xffff; + data[1810] = (char) 0xffff; + data[1811] = (char) 0xffff; + data[1812] = (char) 0xffff; + data[1813] = (char) 0xffff; + data[1814] = (char) 0xffff; + data[1815] = (char) 0xffff; + data[1816] = (char) 0xffff; + data[1817] = (char) 0xffff; + data[1818] = (char) 0xffff; + data[1819] = (char) 0xffff; + data[1820] = (char) 0xffff; + data[1821] = (char) 0xffff; + data[1822] = (char) 0xffff; + data[1823] = (char) 0xffff; + data[1824] = (char) 0xffff; + data[1825] = (char) 0xffff; + data[1826] = (char) 0xffff; + data[1827] = (char) 0xffff; + data[1828] = (char) 0xffff; + data[1829] = (char) 0xffff; + data[1830] = (char) 0xffff; + data[1831] = (char) 0xffff; + data[1832] = (char) 0xffff; + data[1833] = (char) 0xffff; + data[1834] = (char) 0xffff; + data[1835] = (char) 0xffff; + data[1836] = (char) 0xffff; + data[1837] = (char) 0xffff; + data[1838] = (char) 0xffff; + data[1839] = (char) 0xffff; + data[1840] = (char) 0xffff; + data[1841] = (char) 0xffff; + data[1842] = (char) 0xffff; + data[1843] = (char) 0xffff; + data[1844] = (char) 0xffff; + data[1845] = (char) 0xffff; + data[1846] = (char) 0xffff; + data[1847] = (char) 0xffff; + data[1848] = (char) 0xffff; + data[1849] = (char) 0xffff; + data[1850] = (char) 0xffff; + data[1851] = (char) 0xffff; + data[1852] = (char) 0xffff; + data[1853] = (char) 0xffff; + data[1854] = (char) 0xffff; + data[1855] = (char) 0xffff; + data[1856] = (char) 0xffff; + data[1857] = (char) 0xffff; + data[1858] = (char) 0xffff; + data[1859] = (char) 0xffff; + data[1860] = (char) 0xffff; + data[1861] = (char) 0xffff; + data[1862] = (char) 0xffff; + data[1863] = (char) 0xffff; + data[1864] = (char) 0xffff; + data[1865] = (char) 0xffff; + data[1866] = (char) 0xffff; + data[1867] = (char) 0xffff; + data[1868] = (char) 0xffff; + data[1869] = (char) 0xffff; + data[1870] = (char) 0xffff; + data[1871] = (char) 0xffff; + data[1872] = (char) 0xffff; + data[1873] = (char) 0xffff; + data[1874] = (char) 0xffff; + data[1875] = (char) 0xffff; + data[1876] = (char) 0xffff; + data[1877] = (char) 0xffff; + data[1878] = (char) 0xffff; + data[1879] = (char) 0xffff; + data[1880] = (char) 0xffff; + data[1881] = (char) 0xffff; + data[1882] = (char) 0xffff; + data[1883] = (char) 0xffff; + data[1884] = (char) 0xffff; + data[1885] = (char) 0xffff; + data[1886] = (char) 0xffff; + data[1887] = (char) 0xffff; + data[1888] = (char) 0xffff; + data[1889] = (char) 0xffff; + data[1890] = (char) 0xffff; + data[1891] = (char) 0xffff; + data[1892] = (char) 0xffff; + data[1893] = (char) 0xffff; + data[1894] = (char) 0xffff; + data[1895] = (char) 0xffff; + data[1896] = (char) 0xffff; + data[1897] = (char) 0xffff; + data[1898] = (char) 0xffff; + data[1899] = (char) 0xffff; + data[1900] = (char) 0xffff; + data[1901] = (char) 0xffff; + data[1902] = (char) 0xffff; + data[1903] = (char) 0xffff; + data[1904] = (char) 0xffff; + data[1905] = (char) 0xffff; + data[1906] = (char) 0xffff; + data[1907] = (char) 0xffff; + data[1908] = (char) 0xffff; + data[1909] = (char) 0xffff; + data[1910] = (char) 0xffff; + data[1911] = (char) 0xffff; + data[1912] = (char) 0xffff; + data[1913] = (char) 0xffff; + data[1914] = (char) 0xffff; + data[1915] = (char) 0xffff; + data[1916] = (char) 0xffff; + data[1917] = (char) 0xffff; + data[1918] = (char) 0xffff; + data[1919] = (char) 0xffff; + data[1920] = (char) 0xffff; + data[1921] = (char) 0xffff; + data[1922] = (char) 0xffff; + data[1923] = (char) 0xffff; + data[1924] = (char) 0xffff; + data[1925] = (char) 0xffff; + data[1926] = (char) 0xffff; + data[1927] = (char) 0xffff; + data[1928] = (char) 0xffff; + data[1929] = (char) 0xffff; + data[1930] = (char) 0xffff; + data[1931] = (char) 0xffff; + data[1932] = (char) 0xffff; + data[1933] = (char) 0xffff; + data[1934] = (char) 0xffff; + data[1935] = (char) 0xffff; + data[1936] = (char) 0xffff; + data[1937] = (char) 0xffff; + data[1938] = (char) 0xffff; + data[1939] = (char) 0xffff; + data[1940] = (char) 0xffff; + data[1941] = (char) 0xffff; + data[1942] = (char) 0xffff; + data[1943] = (char) 0xffff; + data[1944] = (char) 0xffff; + data[1945] = (char) 0xffff; + data[1946] = (char) 0xffff; + data[1947] = (char) 0xffff; + data[1948] = (char) 0xffff; + data[1949] = (char) 0xffff; + data[1950] = (char) 0xffff; + data[1951] = (char) 0xffff; + data[1952] = (char) 0xffff; + data[1953] = (char) 0xffff; + data[1954] = (char) 0xffff; + data[1955] = (char) 0xffff; + data[1956] = (char) 0xffff; + data[1957] = (char) 0xffff; + data[1958] = (char) 0xffff; + data[1959] = (char) 0xffff; + data[1960] = (char) 0xffff; + data[1961] = (char) 0xffff; + data[1962] = (char) 0xffff; + data[1963] = (char) 0xffff; + data[1964] = (char) 0xffff; + data[1965] = (char) 0xffff; + data[1966] = (char) 0xffff; + data[1967] = (char) 0xffff; + data[1968] = (char) 0xffff; + data[1969] = (char) 0xffff; + data[1970] = (char) 0xffff; + data[1971] = (char) 0xffff; + data[1972] = (char) 0xffff; + data[1973] = (char) 0xffff; + data[1974] = (char) 0xffff; + data[1975] = (char) 0xffff; + data[1976] = (char) 0xffff; + data[1977] = (char) 0xffff; + data[1978] = (char) 0xffff; + data[1979] = (char) 0xffff; + data[1980] = (char) 0xffff; + data[1981] = (char) 0xffff; + data[1982] = (char) 0xffff; + data[1983] = (char) 0xffff; + data[1984] = (char) 0xffff; + data[1985] = (char) 0xffff; + data[1986] = (char) 0xffff; + data[1987] = (char) 0xffff; + data[1988] = (char) 0xffff; + data[1989] = (char) 0xffff; + data[1990] = (char) 0xffff; + data[1991] = (char) 0xffff; + data[1992] = (char) 0xffff; + data[1993] = (char) 0xffff; + data[1994] = (char) 0xffff; + data[1995] = (char) 0xffff; + data[1996] = (char) 0xffff; + data[1997] = (char) 0xffff; + data[1998] = (char) 0xffff; + data[1999] = (char) 0xffff; + data[2000] = (char) 0xffff; + data[2001] = (char) 0xffff; + data[2002] = (char) 0xffff; + data[2003] = (char) 0xffff; + data[2004] = (char) 0xffff; + data[2005] = (char) 0xffff; + data[2006] = (char) 0xffff; + data[2007] = (char) 0xffff; + data[2008] = (char) 0xffff; + data[2009] = (char) 0xffff; + data[2010] = (char) 0xffff; + data[2011] = (char) 0xffff; + data[2012] = (char) 0xffff; + data[2013] = (char) 0xffff; + data[2014] = (char) 0xffff; + data[2015] = (char) 0xffff; + data[2016] = (char) 0xffff; + data[2017] = (char) 0xffff; + data[2018] = (char) 0xffff; + data[2019] = (char) 0xffff; + data[2020] = (char) 0xffff; + data[2021] = (char) 0xffff; + data[2022] = (char) 0xffff; + data[2023] = (char) 0xffff; + data[2024] = (char) 0xffff; + data[2025] = (char) 0xffff; + data[2026] = (char) 0xffff; + data[2027] = (char) 0xffff; + data[2028] = (char) 0xffff; + data[2029] = (char) 0xffff; + data[2030] = (char) 0xffff; + data[2031] = (char) 0xffff; + data[2032] = (char) 0xffff; + data[2033] = (char) 0xffff; + data[2034] = (char) 0xffff; + data[2035] = (char) 0xffff; + data[2036] = (char) 0xffff; + data[2037] = (char) 0xffff; + data[2038] = (char) 0xffff; + data[2039] = (char) 0xffff; + data[2040] = (char) 0xffff; + data[2041] = (char) 0xffff; + data[2042] = (char) 0xffff; + data[2043] = (char) 0xffff; + data[2044] = (char) 0xffff; + data[2045] = (char) 0xffff; + data[2046] = (char) 0xffff; + data[2047] = (char) 0xffff; + data[2048] = (char) 0xffff; + data[2049] = (char) 0xffff; + data[2050] = (char) 0xffff; + data[2051] = (char) 0xffff; + data[2052] = (char) 0xffff; + data[2053] = (char) 0xffff; + data[2054] = (char) 0xffff; + data[2055] = (char) 0xffff; + data[2056] = (char) 0xffff; + data[2057] = (char) 0xffff; + data[2058] = (char) 0xffff; + data[2059] = (char) 0xffff; + data[2060] = (char) 0xffff; + data[2061] = (char) 0xffff; + data[2062] = (char) 0xffff; + data[2063] = (char) 0xffff; + data[2064] = (char) 0xffff; + data[2065] = (char) 0xffff; + data[2066] = (char) 0xffff; + data[2067] = (char) 0xffff; + data[2068] = (char) 0xffff; + data[2069] = (char) 0xffff; + data[2070] = (char) 0xffff; + data[2071] = (char) 0xffff; + data[2072] = (char) 0xffff; + data[2073] = (char) 0xffff; + data[2074] = (char) 0xffff; + data[2075] = (char) 0xffff; + data[2076] = (char) 0xffff; + data[2077] = (char) 0xffff; + data[2078] = (char) 0xffff; + data[2079] = (char) 0xffff; + data[2080] = (char) 0xffff; + data[2081] = (char) 0xffff; + data[2082] = (char) 0xffff; + data[2083] = (char) 0xffff; + data[2084] = (char) 0xffff; + data[2085] = (char) 0xffff; + data[2086] = (char) 0xffff; + data[2087] = (char) 0xffff; + data[2088] = (char) 0xffff; + data[2089] = (char) 0xffff; + data[2090] = (char) 0xffff; + data[2091] = (char) 0xffff; + data[2092] = (char) 0xffff; + data[2093] = (char) 0xffff; + data[2094] = (char) 0xffff; + data[2095] = (char) 0xffff; + data[2096] = (char) 0xffff; + data[2097] = (char) 0xffff; + data[2098] = (char) 0xffff; + data[2099] = (char) 0xffff; + data[2100] = (char) 0xffff; + data[2101] = (char) 0xffff; + data[2102] = (char) 0xffff; + data[2103] = (char) 0xffff; + data[2104] = (char) 0xffff; + data[2105] = (char) 0xffff; + data[2106] = (char) 0xffff; + data[2107] = (char) 0xffff; + data[2108] = (char) 0xffff; + data[2109] = (char) 0xffff; + data[2110] = (char) 0xffff; + data[2111] = (char) 0xffff; + data[2112] = (char) 0xffff; + data[2113] = (char) 0xffff; + data[2114] = (char) 0xffff; + data[2115] = (char) 0xffff; + data[2116] = (char) 0xffff; + data[2117] = (char) 0xffff; + data[2118] = (char) 0xffff; + data[2119] = (char) 0xffff; + data[2120] = (char) 0xffff; + data[2121] = (char) 0xffff; + data[2122] = (char) 0xffff; + data[2123] = (char) 0xffff; + data[2124] = (char) 0xffff; + data[2125] = (char) 0xffff; + data[2126] = (char) 0xffff; + data[2127] = (char) 0xffff; + data[2128] = (char) 0xffff; + data[2129] = (char) 0xffff; + data[2130] = (char) 0xffff; + data[2131] = (char) 0xffff; + data[2132] = (char) 0xffff; + data[2133] = (char) 0xffff; + data[2134] = (char) 0xffff; + data[2135] = (char) 0xffff; + data[2136] = (char) 0xffff; + data[2137] = (char) 0xffff; + data[2138] = (char) 0xffff; + data[2139] = (char) 0xffff; + data[2140] = (char) 0xffff; + data[2141] = (char) 0xffff; + data[2142] = (char) 0xffff; + data[2143] = (char) 0xffff; + data[2144] = (char) 0xffff; + data[2145] = (char) 0xffff; + data[2146] = (char) 0xffff; + data[2147] = (char) 0xffff; + data[2148] = (char) 0xffff; + data[2149] = (char) 0xffff; + data[2150] = (char) 0xffff; + data[2151] = (char) 0xffff; + data[2152] = (char) 0xffff; + data[2153] = (char) 0xffff; + data[2154] = (char) 0xffff; + data[2155] = (char) 0xffff; + data[2156] = (char) 0xffff; + data[2157] = (char) 0xffff; + data[2158] = (char) 0xffff; + data[2159] = (char) 0xffff; + data[2160] = (char) 0xffff; + data[2161] = (char) 0xffff; + data[2162] = (char) 0xffff; + data[2163] = (char) 0xffff; + data[2164] = (char) 0xffff; + data[2165] = (char) 0xffff; + data[2166] = (char) 0xffff; + data[2167] = (char) 0xffff; + data[2168] = (char) 0xffff; + data[2169] = (char) 0xffff; + data[2170] = (char) 0xffff; + data[2171] = (char) 0xffff; + data[2172] = (char) 0xffff; + data[2173] = (char) 0xffff; + data[2174] = (char) 0xffff; + data[2175] = (char) 0xffff; + data[2176] = (char) 0xffff; + data[2177] = (char) 0xffff; + data[2178] = (char) 0xffff; + data[2179] = (char) 0xffff; + data[2180] = (char) 0xffff; + data[2181] = (char) 0xffff; + data[2182] = (char) 0xffff; + data[2183] = (char) 0xffff; + data[2184] = (char) 0xffff; + data[2185] = (char) 0xffff; + data[2186] = (char) 0xffff; + data[2187] = (char) 0xffff; + data[2188] = (char) 0xffff; + data[2189] = (char) 0xffff; + data[2190] = (char) 0xffff; + data[2191] = (char) 0xffff; + data[2192] = (char) 0xffff; + data[2193] = (char) 0xffff; + data[2194] = (char) 0xffff; + data[2195] = (char) 0xffff; + data[2196] = (char) 0xffff; + data[2197] = (char) 0xffff; + data[2198] = (char) 0xffff; + data[2199] = (char) 0xffff; + data[2200] = (char) 0xffff; + data[2201] = (char) 0xffff; + data[2202] = (char) 0xffff; + data[2203] = (char) 0xffff; + data[2204] = (char) 0xffff; + data[2205] = (char) 0xffff; + data[2206] = (char) 0xffff; + data[2207] = (char) 0xffff; + data[2208] = (char) 0xffff; + data[2209] = (char) 0xffff; + data[2210] = (char) 0xffff; + data[2211] = (char) 0xffff; + data[2212] = (char) 0xffff; + data[2213] = (char) 0xffff; + data[2214] = (char) 0xffff; + data[2215] = (char) 0xffff; + data[2216] = (char) 0xffff; + data[2217] = (char) 0xffff; + data[2218] = (char) 0xffff; + data[2219] = (char) 0xffff; + data[2220] = (char) 0xffff; + data[2221] = (char) 0xffff; + data[2222] = (char) 0xffff; + data[2223] = (char) 0xffff; + data[2224] = (char) 0xffff; + data[2225] = (char) 0xffff; + data[2226] = (char) 0xffff; + data[2227] = (char) 0xffff; + data[2228] = (char) 0xffff; + data[2229] = (char) 0xffff; + data[2230] = (char) 0xffff; + data[2231] = (char) 0xffff; + data[2232] = (char) 0xffff; + data[2233] = (char) 0xffff; + data[2234] = (char) 0xffff; + data[2235] = (char) 0xffff; + data[2236] = (char) 0xffff; + data[2237] = (char) 0xffff; + data[2238] = (char) 0xffff; + data[2239] = (char) 0xffff; + data[2240] = (char) 0xffff; + data[2241] = (char) 0xffff; + data[2242] = (char) 0xffff; + data[2243] = (char) 0xffff; + data[2244] = (char) 0xffff; + data[2245] = (char) 0xffff; + data[2246] = (char) 0xffff; + data[2247] = (char) 0xffff; + data[2248] = (char) 0xffff; + data[2249] = (char) 0xffff; + data[2250] = (char) 0xffff; + data[2251] = (char) 0xffff; + data[2252] = (char) 0xffff; + data[2253] = (char) 0xffff; + data[2254] = (char) 0xffff; + data[2255] = (char) 0xffff; + data[2256] = (char) 0xffff; + data[2257] = (char) 0xffff; + data[2258] = (char) 0xffff; + data[2259] = (char) 0xffff; + data[2260] = (char) 0xffff; + data[2261] = (char) 0xffff; + data[2262] = (char) 0xffff; + data[2263] = (char) 0xffff; + data[2264] = (char) 0xffff; + data[2265] = (char) 0xffff; + data[2266] = (char) 0xffff; + data[2267] = (char) 0xffff; + data[2268] = (char) 0xffff; + data[2269] = (char) 0xffff; + data[2270] = (char) 0xffff; + data[2271] = (char) 0xffff; + data[2272] = (char) 0xffff; + data[2273] = (char) 0xffff; + data[2274] = (char) 0xffff; + data[2275] = (char) 0xffff; + data[2276] = (char) 0xffff; + data[2277] = (char) 0xffff; + data[2278] = (char) 0xffff; + data[2279] = (char) 0xffff; + data[2280] = (char) 0xffff; + data[2281] = (char) 0xffff; + data[2282] = (char) 0xffff; + data[2283] = (char) 0xffff; + data[2284] = (char) 0xffff; + data[2285] = (char) 0xffff; + data[2286] = (char) 0xffff; + data[2287] = (char) 0xffff; + data[2288] = (char) 0xffff; + data[2289] = (char) 0xffff; + data[2290] = (char) 0xffff; + data[2291] = (char) 0xffff; + data[2292] = (char) 0xffff; + data[2293] = (char) 0xffff; + data[2294] = (char) 0xffff; + data[2295] = (char) 0xffff; + data[2296] = (char) 0xffff; + data[2297] = (char) 0xffff; + data[2298] = (char) 0xffff; + data[2299] = (char) 0xffff; + data[2300] = (char) 0xffff; + data[2301] = (char) 0xffff; + data[2302] = (char) 0xffff; + data[2303] = (char) 0xffff; + data[2304] = (char) 0xffff; + data[2305] = (char) 0xffff; + data[2306] = (char) 0xffff; + data[2307] = (char) 0xffff; + data[2308] = (char) 0xffff; + data[2309] = (char) 0xffff; + data[2310] = (char) 0xffff; + data[2311] = (char) 0xffff; + data[2312] = (char) 0xffff; + data[2313] = (char) 0xffff; + data[2314] = (char) 0xffff; + data[2315] = (char) 0xffff; + data[2316] = (char) 0xffff; + data[2317] = (char) 0xffff; + data[2318] = (char) 0xffff; + data[2319] = (char) 0xffff; + data[2320] = (char) 0xffff; + data[2321] = (char) 0xffff; + data[2322] = (char) 0xffff; + data[2323] = (char) 0xffff; + data[2324] = (char) 0xffff; + data[2325] = (char) 0xffff; + data[2326] = (char) 0xffff; + data[2327] = (char) 0xffff; + data[2328] = (char) 0xffff; + data[2329] = (char) 0xffff; + data[2330] = (char) 0xffff; + data[2331] = (char) 0xffff; + data[2332] = (char) 0xffff; + data[2333] = (char) 0xffff; + data[2334] = (char) 0xffff; + data[2335] = (char) 0xffff; + data[2336] = (char) 0xffff; + data[2337] = (char) 0xffff; + data[2338] = (char) 0xffff; + data[2339] = (char) 0xffff; + data[2340] = (char) 0xffff; + data[2341] = (char) 0xffff; + data[2342] = (char) 0xffff; + data[2343] = (char) 0xffff; + data[2344] = (char) 0xffff; + data[2345] = (char) 0xffff; + data[2346] = (char) 0xffff; + data[2347] = (char) 0xffff; + data[2348] = (char) 0xffff; + data[2349] = (char) 0xffff; + data[2350] = (char) 0xffff; + data[2351] = (char) 0xffff; + data[2352] = (char) 0xffff; + data[2353] = (char) 0xffff; + data[2354] = (char) 0xffff; + data[2355] = (char) 0xffff; + data[2356] = (char) 0xffff; + data[2357] = (char) 0xffff; + data[2358] = (char) 0xffff; + data[2359] = (char) 0xffff; + data[2360] = (char) 0xffff; + data[2361] = (char) 0xffff; + data[2362] = (char) 0xffff; + data[2363] = (char) 0xffff; + data[2364] = (char) 0xffff; + data[2365] = (char) 0xffff; + data[2366] = (char) 0xffff; + data[2367] = (char) 0xffff; + data[2368] = (char) 0xffff; + data[2369] = (char) 0xffff; + data[2370] = (char) 0xffff; + data[2371] = (char) 0xffff; + data[2372] = (char) 0xffff; + data[2373] = (char) 0xffff; + data[2374] = (char) 0xffff; + data[2375] = (char) 0xffff; + data[2376] = (char) 0xffff; + data[2377] = (char) 0xffff; + data[2378] = (char) 0xffff; + data[2379] = (char) 0xffff; + data[2380] = (char) 0xffff; + data[2381] = (char) 0xffff; + data[2382] = (char) 0xffff; + data[2383] = (char) 0xffff; + data[2384] = (char) 0xffff; + data[2385] = (char) 0xffff; + data[2386] = (char) 0xffff; + data[2387] = (char) 0xffff; + data[2388] = (char) 0xffff; + data[2389] = (char) 0xffff; + data[2390] = (char) 0xffff; + data[2391] = (char) 0xffff; + data[2392] = (char) 0xffff; + data[2393] = (char) 0xffff; + data[2394] = (char) 0xffff; + data[2395] = (char) 0xffff; + data[2396] = (char) 0xffff; + data[2397] = (char) 0xffff; + data[2398] = (char) 0xffff; + data[2399] = (char) 0xffff; + data[2400] = (char) 0xffff; + data[2401] = (char) 0xffff; + data[2402] = (char) 0xffff; + data[2403] = (char) 0xffff; + data[2404] = (char) 0xffff; + data[2405] = (char) 0xffff; + data[2406] = (char) 0xffff; + data[2407] = (char) 0xffff; + data[2408] = (char) 0xffff; + data[2409] = (char) 0xffff; + data[2410] = (char) 0xffff; + data[2411] = (char) 0xffff; + data[2412] = (char) 0xffff; + data[2413] = (char) 0xffff; + data[2414] = (char) 0xffff; + data[2415] = (char) 0xffff; + data[2416] = (char) 0xffff; + data[2417] = (char) 0xffff; + data[2418] = (char) 0xffff; + data[2419] = (char) 0xffff; + data[2420] = (char) 0xffff; + data[2421] = (char) 0xffff; + data[2422] = (char) 0xffff; + data[2423] = (char) 0xffff; + data[2424] = (char) 0xffff; + data[2425] = (char) 0xffff; + data[2426] = (char) 0xffff; + data[2427] = (char) 0xffff; + data[2428] = (char) 0xffff; + data[2429] = (char) 0xffff; + data[2430] = (char) 0xffff; + data[2431] = (char) 0xffff; + data[2432] = (char) 0xffff; + data[2433] = (char) 0xffff; + data[2434] = (char) 0xffff; + data[2435] = (char) 0xffff; + data[2436] = (char) 0xffff; + data[2437] = (char) 0xffff; + data[2438] = (char) 0xffff; + data[2439] = (char) 0xffff; + data[2440] = (char) 0xffff; + data[2441] = (char) 0xffff; + data[2442] = (char) 0xffff; + data[2443] = (char) 0xffff; + data[2444] = (char) 0xffff; + data[2445] = (char) 0xffff; + data[2446] = (char) 0xffff; + data[2447] = (char) 0xffff; + data[2448] = (char) 0xffff; + data[2449] = (char) 0xffff; + data[2450] = (char) 0xffff; + data[2451] = (char) 0xffff; + data[2452] = (char) 0xffff; + data[2453] = (char) 0xffff; + data[2454] = (char) 0xffff; + data[2455] = (char) 0xffff; + data[2456] = (char) 0xffff; + data[2457] = (char) 0xffff; + data[2458] = (char) 0xffff; + data[2459] = (char) 0xffff; + data[2460] = (char) 0xffff; + data[2461] = (char) 0xffff; + data[2462] = (char) 0xffff; + data[2463] = (char) 0xffff; + data[2464] = (char) 0xffff; + data[2465] = (char) 0xffff; + data[2466] = (char) 0xffff; + data[2467] = (char) 0xffff; + data[2468] = (char) 0xffff; + data[2469] = (char) 0xffff; + data[2470] = (char) 0xffff; + data[2471] = (char) 0xffff; + data[2472] = (char) 0xffff; + data[2473] = (char) 0xffff; + data[2474] = (char) 0xffff; + data[2475] = (char) 0xffff; + data[2476] = (char) 0xffff; + data[2477] = (char) 0xffff; + data[2478] = (char) 0xffff; + data[2479] = (char) 0xffff; + data[2480] = (char) 0xffff; + data[2481] = (char) 0xffff; + data[2482] = (char) 0xffff; + data[2483] = (char) 0xffff; + data[2484] = (char) 0xffff; + data[2485] = (char) 0xffff; + data[2486] = (char) 0xffff; + data[2487] = (char) 0xffff; + data[2488] = (char) 0xffff; + data[2489] = (char) 0xffff; + data[2490] = (char) 0xffff; + data[2491] = (char) 0xffff; + data[2492] = (char) 0xffff; + data[2493] = (char) 0xffff; + data[2494] = (char) 0xffff; + data[2495] = (char) 0xffff; + data[2496] = (char) 0xffff; + data[2497] = (char) 0xffff; + data[2498] = (char) 0xffff; + data[2499] = (char) 0xffff; + data[2500] = (char) 0xffff; + data[2501] = (char) 0xffff; + data[2502] = (char) 0xffff; + data[2503] = (char) 0xffff; + data[2504] = (char) 0xffff; + data[2505] = (char) 0xffff; + data[2506] = (char) 0xffff; + data[2507] = (char) 0xffff; + data[2508] = (char) 0xffff; + data[2509] = (char) 0xffff; + data[2510] = (char) 0xffff; + data[2511] = (char) 0xffff; + data[2512] = (char) 0xffff; + data[2513] = (char) 0xffff; + data[2514] = (char) 0xffff; + data[2515] = (char) 0xffff; + data[2516] = (char) 0xffff; + data[2517] = (char) 0xffff; + data[2518] = (char) 0xffff; + data[2519] = (char) 0xffff; + data[2520] = (char) 0xffff; + data[2521] = (char) 0xffff; + data[2522] = (char) 0xffff; + data[2523] = (char) 0xffff; + data[2524] = (char) 0xffff; + data[2525] = (char) 0xffff; + data[2526] = (char) 0xffff; + data[2527] = (char) 0xffff; + data[2528] = (char) 0xffff; + data[2529] = (char) 0xffff; + data[2530] = (char) 0xffff; + data[2531] = (char) 0xffff; + data[2532] = (char) 0xffff; + data[2533] = (char) 0xffff; + data[2534] = (char) 0xffff; + data[2535] = (char) 0xffff; + data[2536] = (char) 0xffff; + data[2537] = (char) 0xffff; + data[2538] = (char) 0xffff; + data[2539] = (char) 0xffff; + data[2540] = (char) 0xffff; + data[2541] = (char) 0xffff; + data[2542] = (char) 0xffff; + data[2543] = (char) 0xffff; + data[2544] = (char) 0xffff; + data[2545] = (char) 0xffff; + data[2546] = (char) 0xffff; + data[2547] = (char) 0xffff; + data[2548] = (char) 0xffff; + data[2549] = (char) 0xffff; + data[2550] = (char) 0xffff; + data[2551] = (char) 0xffff; + data[2552] = (char) 0xffff; + data[2553] = (char) 0xffff; + data[2554] = (char) 0x003f; + data[2752] = (char) 0xffff; + data[2753] = (char) 0xffff; + data[2754] = (char) 0xffff; + data[2755] = (char) 0xffff; + data[2756] = (char) 0xffff; + data[2757] = (char) 0xffff; + data[2758] = (char) 0xffff; + data[2759] = (char) 0xffff; + data[2760] = (char) 0xffff; + data[2761] = (char) 0xffff; + data[2762] = (char) 0xffff; + data[2763] = (char) 0xffff; + data[2764] = (char) 0xffff; + data[2765] = (char) 0xffff; + data[2766] = (char) 0xffff; + data[2767] = (char) 0xffff; + data[2768] = (char) 0xffff; + data[2769] = (char) 0xffff; + data[2770] = (char) 0xffff; + data[2771] = (char) 0xffff; + data[2772] = (char) 0xffff; + data[2773] = (char) 0xffff; + data[2774] = (char) 0xffff; + data[2775] = (char) 0xffff; + data[2776] = (char) 0xffff; + data[2777] = (char) 0xffff; + data[2778] = (char) 0xffff; + data[2779] = (char) 0xffff; + data[2780] = (char) 0xffff; + data[2781] = (char) 0xffff; + data[2782] = (char) 0xffff; + data[2783] = (char) 0xffff; + data[2784] = (char) 0xffff; + data[2785] = (char) 0xffff; + data[2786] = (char) 0xffff; + data[2787] = (char) 0xffff; + data[2788] = (char) 0xffff; + data[2789] = (char) 0xffff; + data[2790] = (char) 0xffff; + data[2791] = (char) 0xffff; + data[2792] = (char) 0xffff; + data[2793] = (char) 0xffff; + data[2794] = (char) 0xffff; + data[2795] = (char) 0xffff; + data[2796] = (char) 0xffff; + data[2797] = (char) 0xffff; + data[2798] = (char) 0xffff; + data[2799] = (char) 0xffff; + data[2800] = (char) 0xffff; + data[2801] = (char) 0xffff; + data[2802] = (char) 0xffff; + data[2803] = (char) 0xffff; + data[2804] = (char) 0xffff; + data[2805] = (char) 0xffff; + data[2806] = (char) 0xffff; + data[2807] = (char) 0xffff; + data[2808] = (char) 0xffff; + data[2809] = (char) 0xffff; + data[2810] = (char) 0xffff; + data[2811] = (char) 0xffff; + data[2812] = (char) 0xffff; + data[2813] = (char) 0xffff; + data[2814] = (char) 0xffff; + data[2815] = (char) 0xffff; + data[2816] = (char) 0xffff; + data[2817] = (char) 0xffff; + data[2818] = (char) 0xffff; + data[2819] = (char) 0xffff; + data[2820] = (char) 0xffff; + data[2821] = (char) 0xffff; + data[2822] = (char) 0xffff; + data[2823] = (char) 0xffff; + data[2824] = (char) 0xffff; + data[2825] = (char) 0xffff; + data[2826] = (char) 0xffff; + data[2827] = (char) 0xffff; + data[2828] = (char) 0xffff; + data[2829] = (char) 0xffff; + data[2830] = (char) 0xffff; + data[2831] = (char) 0xffff; + data[2832] = (char) 0xffff; + data[2833] = (char) 0xffff; + data[2834] = (char) 0xffff; + data[2835] = (char) 0xffff; + data[2836] = (char) 0xffff; + data[2837] = (char) 0xffff; + data[2838] = (char) 0xffff; + data[2839] = (char) 0xffff; + data[2840] = (char) 0xffff; + data[2841] = (char) 0xffff; + data[2842] = (char) 0xffff; + data[2843] = (char) 0xffff; + data[2844] = (char) 0xffff; + data[2845] = (char) 0xffff; + data[2846] = (char) 0xffff; + data[2847] = (char) 0xffff; + data[2848] = (char) 0xffff; + data[2849] = (char) 0xffff; + data[2850] = (char) 0xffff; + data[2851] = (char) 0xffff; + data[2852] = (char) 0xffff; + data[2853] = (char) 0xffff; + data[2854] = (char) 0xffff; + data[2855] = (char) 0xffff; + data[2856] = (char) 0xffff; + data[2857] = (char) 0xffff; + data[2858] = (char) 0xffff; + data[2859] = (char) 0xffff; + data[2860] = (char) 0xffff; + data[2861] = (char) 0xffff; + data[2862] = (char) 0xffff; + data[2863] = (char) 0xffff; + data[2864] = (char) 0xffff; + data[2865] = (char) 0xffff; + data[2866] = (char) 0xffff; + data[2867] = (char) 0xffff; + data[2868] = (char) 0xffff; + data[2869] = (char) 0xffff; + data[2870] = (char) 0xffff; + data[2871] = (char) 0xffff; + data[2872] = (char) 0xffff; + data[2873] = (char) 0xffff; + data[2874] = (char) 0xffff; + data[2875] = (char) 0xffff; + data[2876] = (char) 0xffff; + data[2877] = (char) 0xffff; + data[2878] = (char) 0xffff; + data[2879] = (char) 0xffff; + data[2880] = (char) 0xffff; + data[2881] = (char) 0xffff; + data[2882] = (char) 0xffff; + data[2883] = (char) 0xffff; + data[2884] = (char) 0xffff; + data[2885] = (char) 0xffff; + data[2886] = (char) 0xffff; + data[2887] = (char) 0xffff; + data[2888] = (char) 0xffff; + data[2889] = (char) 0xffff; + data[2890] = (char) 0xffff; + data[2891] = (char) 0xffff; + data[2892] = (char) 0xffff; + data[2893] = (char) 0xffff; + data[2894] = (char) 0xffff; + data[2895] = (char) 0xffff; + data[2896] = (char) 0xffff; + data[2897] = (char) 0xffff; + data[2898] = (char) 0xffff; + data[2899] = (char) 0xffff; + data[2900] = (char) 0xffff; + data[2901] = (char) 0xffff; + data[2902] = (char) 0xffff; + data[2903] = (char) 0xffff; + data[2904] = (char) 0xffff; + data[2905] = (char) 0xffff; + data[2906] = (char) 0xffff; + data[2907] = (char) 0xffff; + data[2908] = (char) 0xffff; + data[2909] = (char) 0xffff; + data[2910] = (char) 0xffff; + data[2911] = (char) 0xffff; + data[2912] = (char) 0xffff; + data[2913] = (char) 0xffff; + data[2914] = (char) 0xffff; + data[2915] = (char) 0xffff; + data[2916] = (char) 0xffff; + data[2917] = (char) 0xffff; + data[2918] = (char) 0xffff; + data[2919] = (char) 0xffff; + data[2920] = (char) 0xffff; + data[2921] = (char) 0xffff; + data[2922] = (char) 0xffff; + data[2923] = (char) 0xffff; + data[2924] = (char) 0xffff; + data[2925] = (char) 0xffff; + data[2926] = (char) 0xffff; + data[2927] = (char) 0xffff; + data[2928] = (char) 0xffff; + data[2929] = (char) 0xffff; + data[2930] = (char) 0xffff; + data[2931] = (char) 0xffff; + data[2932] = (char) 0xffff; + data[2933] = (char) 0xffff; + data[2934] = (char) 0xffff; + data[2935] = (char) 0xffff; + data[2936] = (char) 0xffff; + data[2937] = (char) 0xffff; + data[2938] = (char) 0xffff; + data[2939] = (char) 0xffff; + data[2940] = (char) 0xffff; + data[2941] = (char) 0xffff; + data[2942] = (char) 0xffff; + data[2943] = (char) 0xffff; + data[2944] = (char) 0xffff; + data[2945] = (char) 0xffff; + data[2946] = (char) 0xffff; + data[2947] = (char) 0xffff; + data[2948] = (char) 0xffff; + data[2949] = (char) 0xffff; + data[2950] = (char) 0xffff; + data[2951] = (char) 0xffff; + data[2952] = (char) 0xffff; + data[2953] = (char) 0xffff; + data[2954] = (char) 0xffff; + data[2955] = (char) 0xffff; + data[2956] = (char) 0xffff; + data[2957] = (char) 0xffff; + data[2958] = (char) 0xffff; + data[2959] = (char) 0xffff; + data[2960] = (char) 0xffff; + data[2961] = (char) 0xffff; + data[2962] = (char) 0xffff; + data[2963] = (char) 0xffff; + data[2964] = (char) 0xffff; + data[2965] = (char) 0xffff; + data[2966] = (char) 0xffff; + data[2967] = (char) 0xffff; + data[2968] = (char) 0xffff; + data[2969] = (char) 0xffff; + data[2970] = (char) 0xffff; + data[2971] = (char) 0xffff; + data[2972] = (char) 0xffff; + data[2973] = (char) 0xffff; + data[2974] = (char) 0xffff; + data[2975] = (char) 0xffff; + data[2976] = (char) 0xffff; + data[2977] = (char) 0xffff; + data[2978] = (char) 0xffff; + data[2979] = (char) 0xffff; + data[2980] = (char) 0xffff; + data[2981] = (char) 0xffff; + data[2982] = (char) 0xffff; + data[2983] = (char) 0xffff; + data[2984] = (char) 0xffff; + data[2985] = (char) 0xffff; + data[2986] = (char) 0xffff; + data[2987] = (char) 0xffff; + data[2988] = (char) 0xffff; + data[2989] = (char) 0xffff; + data[2990] = (char) 0xffff; + data[2991] = (char) 0xffff; + data[2992] = (char) 0xffff; + data[2993] = (char) 0xffff; + data[2994] = (char) 0xffff; + data[2995] = (char) 0xffff; + data[2996] = (char) 0xffff; + data[2997] = (char) 0xffff; + data[2998] = (char) 0xffff; + data[2999] = (char) 0xffff; + data[3000] = (char) 0xffff; + data[3001] = (char) 0xffff; + data[3002] = (char) 0xffff; + data[3003] = (char) 0xffff; + data[3004] = (char) 0xffff; + data[3005] = (char) 0xffff; + data[3006] = (char) 0xffff; + data[3007] = (char) 0xffff; + data[3008] = (char) 0xffff; + data[3009] = (char) 0xffff; + data[3010] = (char) 0xffff; + data[3011] = (char) 0xffff; + data[3012] = (char) 0xffff; + data[3013] = (char) 0xffff; + data[3014] = (char) 0xffff; + data[3015] = (char) 0xffff; + data[3016] = (char) 0xffff; + data[3017] = (char) 0xffff; + data[3018] = (char) 0xffff; + data[3019] = (char) 0xffff; + data[3020] = (char) 0xffff; + data[3021] = (char) 0xffff; + data[3022] = (char) 0xffff; + data[3023] = (char) 0xffff; + data[3024] = (char) 0xffff; + data[3025] = (char) 0xffff; + data[3026] = (char) 0xffff; + data[3027] = (char) 0xffff; + data[3028] = (char) 0xffff; + data[3029] = (char) 0xffff; + data[3030] = (char) 0xffff; + data[3031] = (char) 0xffff; + data[3032] = (char) 0xffff; + data[3033] = (char) 0xffff; + data[3034] = (char) 0xffff; + data[3035] = (char) 0xffff; + data[3036] = (char) 0xffff; + data[3037] = (char) 0xffff; + data[3038] = (char) 0xffff; + data[3039] = (char) 0xffff; + data[3040] = (char) 0xffff; + data[3041] = (char) 0xffff; + data[3042] = (char) 0xffff; + data[3043] = (char) 0xffff; + data[3044] = (char) 0xffff; + data[3045] = (char) 0xffff; + data[3046] = (char) 0xffff; + data[3047] = (char) 0xffff; + data[3048] = (char) 0xffff; + data[3049] = (char) 0xffff; + data[3050] = (char) 0xffff; + data[3051] = (char) 0xffff; + data[3052] = (char) 0xffff; + data[3053] = (char) 0xffff; + data[3054] = (char) 0xffff; + data[3055] = (char) 0xffff; + data[3056] = (char) 0xffff; + data[3057] = (char) 0xffff; + data[3058] = (char) 0xffff; + data[3059] = (char) 0xffff; + data[3060] = (char) 0xffff; + data[3061] = (char) 0xffff; + data[3062] = (char) 0xffff; + data[3063] = (char) 0xffff; + data[3064] = (char) 0xffff; + data[3065] = (char) 0xffff; + data[3066] = (char) 0xffff; + data[3067] = (char) 0xffff; + data[3068] = (char) 0xffff; + data[3069] = (char) 0xffff; + data[3070] = (char) 0xffff; + data[3071] = (char) 0xffff; + data[3072] = (char) 0xffff; + data[3073] = (char) 0xffff; + data[3074] = (char) 0xffff; + data[3075] = (char) 0xffff; + data[3076] = (char) 0xffff; + data[3077] = (char) 0xffff; + data[3078] = (char) 0xffff; + data[3079] = (char) 0xffff; + data[3080] = (char) 0xffff; + data[3081] = (char) 0xffff; + data[3082] = (char) 0xffff; + data[3083] = (char) 0xffff; + data[3084] = (char) 0xffff; + data[3085] = (char) 0xffff; + data[3086] = (char) 0xffff; + data[3087] = (char) 0xffff; + data[3088] = (char) 0xffff; + data[3089] = (char) 0xffff; + data[3090] = (char) 0xffff; + data[3091] = (char) 0xffff; + data[3092] = (char) 0xffff; + data[3093] = (char) 0xffff; + data[3094] = (char) 0xffff; + data[3095] = (char) 0xffff; + data[3096] = (char) 0xffff; + data[3097] = (char) 0xffff; + data[3098] = (char) 0xffff; + data[3099] = (char) 0xffff; + data[3100] = (char) 0xffff; + data[3101] = (char) 0xffff; + data[3102] = (char) 0xffff; + data[3103] = (char) 0xffff; + data[3104] = (char) 0xffff; + data[3105] = (char) 0xffff; + data[3106] = (char) 0xffff; + data[3107] = (char) 0xffff; + data[3108] = (char) 0xffff; + data[3109] = (char) 0xffff; + data[3110] = (char) 0xffff; + data[3111] = (char) 0xffff; + data[3112] = (char) 0xffff; + data[3113] = (char) 0xffff; + data[3114] = (char) 0xffff; + data[3115] = (char) 0xffff; + data[3116] = (char) 0xffff; + data[3117] = (char) 0xffff; + data[3118] = (char) 0xffff; + data[3119] = (char) 0xffff; + data[3120] = (char) 0xffff; + data[3121] = (char) 0xffff; + data[3122] = (char) 0xffff; + data[3123] = (char) 0xffff; + data[3124] = (char) 0xffff; + data[3125] = (char) 0xffff; + data[3126] = (char) 0xffff; + data[3127] = (char) 0xffff; + data[3128] = (char) 0xffff; + data[3129] = (char) 0xffff; + data[3130] = (char) 0xffff; + data[3131] = (char) 0xffff; + data[3132] = (char) 0xffff; + data[3133] = (char) 0xffff; + data[3134] = (char) 0xffff; + data[3135] = (char) 0xffff; + data[3136] = (char) 0xffff; + data[3137] = (char) 0xffff; + data[3138] = (char) 0xffff; + data[3139] = (char) 0xffff; + data[3140] = (char) 0xffff; + data[3141] = (char) 0xffff; + data[3142] = (char) 0xffff; + data[3143] = (char) 0xffff; + data[3144] = (char) 0xffff; + data[3145] = (char) 0xffff; + data[3146] = (char) 0xffff; + data[3147] = (char) 0xffff; + data[3148] = (char) 0xffff; + data[3149] = (char) 0xffff; + data[3150] = (char) 0xffff; + data[3151] = (char) 0xffff; + data[3152] = (char) 0xffff; + data[3153] = (char) 0xffff; + data[3154] = (char) 0xffff; + data[3155] = (char) 0xffff; + data[3156] = (char) 0xffff; + data[3157] = (char) 0xffff; + data[3158] = (char) 0xffff; + data[3159] = (char) 0xffff; + data[3160] = (char) 0xffff; + data[3161] = (char) 0xffff; + data[3162] = (char) 0xffff; + data[3163] = (char) 0xffff; + data[3164] = (char) 0xffff; + data[3165] = (char) 0xffff; + data[3166] = (char) 0xffff; + data[3167] = (char) 0xffff; + data[3168] = (char) 0xffff; + data[3169] = (char) 0xffff; + data[3170] = (char) 0xffff; + data[3171] = (char) 0xffff; + data[3172] = (char) 0xffff; + data[3173] = (char) 0xffff; + data[3174] = (char) 0xffff; + data[3175] = (char) 0xffff; + data[3176] = (char) 0xffff; + data[3177] = (char) 0xffff; + data[3178] = (char) 0xffff; + data[3179] = (char) 0xffff; + data[3180] = (char) 0xffff; + data[3181] = (char) 0xffff; + data[3182] = (char) 0xffff; + data[3183] = (char) 0xffff; + data[3184] = (char) 0xffff; + data[3185] = (char) 0xffff; + data[3186] = (char) 0xffff; + data[3187] = (char) 0xffff; + data[3188] = (char) 0xffff; + data[3189] = (char) 0xffff; + data[3190] = (char) 0xffff; + data[3191] = (char) 0xffff; + data[3192] = (char) 0xffff; + data[3193] = (char) 0xffff; + data[3194] = (char) 0xffff; + data[3195] = (char) 0xffff; + data[3196] = (char) 0xffff; + data[3197] = (char) 0xffff; + data[3198] = (char) 0xffff; + data[3199] = (char) 0xffff; + data[3200] = (char) 0xffff; + data[3201] = (char) 0xffff; + data[3202] = (char) 0xffff; + data[3203] = (char) 0xffff; + data[3204] = (char) 0xffff; + data[3205] = (char) 0xffff; + data[3206] = (char) 0xffff; + data[3207] = (char) 0xffff; + data[3208] = (char) 0xffff; + data[3209] = (char) 0xffff; + data[3210] = (char) 0xffff; + data[3211] = (char) 0xffff; + data[3212] = (char) 0xffff; + data[3213] = (char) 0xffff; + data[3214] = (char) 0xffff; + data[3215] = (char) 0xffff; + data[3216] = (char) 0xffff; + data[3217] = (char) 0xffff; + data[3218] = (char) 0xffff; + data[3219] = (char) 0xffff; + data[3220] = (char) 0xffff; + data[3221] = (char) 0xffff; + data[3222] = (char) 0xffff; + data[3223] = (char) 0xffff; + data[3224] = (char) 0xffff; + data[3225] = (char) 0xffff; + data[3226] = (char) 0xffff; + data[3227] = (char) 0xffff; + data[3228] = (char) 0xffff; + data[3229] = (char) 0xffff; + data[3230] = (char) 0xffff; + data[3231] = (char) 0xffff; + data[3232] = (char) 0xffff; + data[3233] = (char) 0xffff; + data[3234] = (char) 0xffff; + data[3235] = (char) 0xffff; + data[3236] = (char) 0xffff; + data[3237] = (char) 0xffff; + data[3238] = (char) 0xffff; + data[3239] = (char) 0xffff; + data[3240] = (char) 0xffff; + data[3241] = (char) 0xffff; + data[3242] = (char) 0xffff; + data[3243] = (char) 0xffff; + data[3244] = (char) 0xffff; + data[3245] = (char) 0xffff; + data[3246] = (char) 0xffff; + data[3247] = (char) 0xffff; + data[3248] = (char) 0xffff; + data[3249] = (char) 0xffff; + data[3250] = (char) 0xffff; + data[3251] = (char) 0xffff; + data[3252] = (char) 0xffff; + data[3253] = (char) 0xffff; + data[3254] = (char) 0xffff; + data[3255] = (char) 0xffff; + data[3256] = (char) 0xffff; + data[3257] = (char) 0xffff; + data[3258] = (char) 0xffff; + data[3259] = (char) 0xffff; + data[3260] = (char) 0xffff; + data[3261] = (char) 0xffff; + data[3262] = (char) 0xffff; + data[3263] = (char) 0xffff; + data[3264] = (char) 0xffff; + data[3265] = (char) 0xffff; + data[3266] = (char) 0xffff; + data[3267] = (char) 0xffff; + data[3268] = (char) 0xffff; + data[3269] = (char) 0xffff; + data[3270] = (char) 0xffff; + data[3271] = (char) 0xffff; + data[3272] = (char) 0xffff; + data[3273] = (char) 0xffff; + data[3274] = (char) 0xffff; + data[3275] = (char) 0xffff; + data[3276] = (char) 0xffff; + data[3277] = (char) 0xffff; + data[3278] = (char) 0xffff; + data[3279] = (char) 0xffff; + data[3280] = (char) 0xffff; + data[3281] = (char) 0xffff; + data[3282] = (char) 0xffff; + data[3283] = (char) 0xffff; + data[3284] = (char) 0xffff; + data[3285] = (char) 0xffff; + data[3286] = (char) 0xffff; + data[3287] = (char) 0xffff; + data[3288] = (char) 0xffff; + data[3289] = (char) 0xffff; + data[3290] = (char) 0xffff; + data[3291] = (char) 0xffff; + data[3292] = (char) 0xffff; + data[3293] = (char) 0xffff; + data[3294] = (char) 0xffff; + data[3295] = (char) 0xffff; + data[3296] = (char) 0xffff; + data[3297] = (char) 0xffff; + data[3298] = (char) 0xffff; + data[3299] = (char) 0xffff; + data[3300] = (char) 0xffff; + data[3301] = (char) 0xffff; + data[3302] = (char) 0xffff; + data[3303] = (char) 0xffff; + data[3304] = (char) 0xffff; + data[3305] = (char) 0xffff; + data[3306] = (char) 0xffff; + data[3307] = (char) 0xffff; + data[3308] = (char) 0xffff; + data[3309] = (char) 0xffff; + data[3310] = (char) 0xffff; + data[3311] = (char) 0xffff; + data[3312] = (char) 0xffff; + data[3313] = (char) 0xffff; + data[3314] = (char) 0xffff; + data[3315] = (char) 0xffff; + data[3316] = (char) 0xffff; + data[3317] = (char) 0xffff; + data[3318] = (char) 0xffff; + data[3319] = (char) 0xffff; + data[3320] = (char) 0xffff; + data[3321] = (char) 0xffff; + data[3322] = (char) 0xffff; + data[3323] = (char) 0xffff; + data[3324] = (char) 0xffff; + data[3325] = (char) 0xffff; + data[3326] = (char) 0xffff; + data[3327] = (char) 0xffff; + data[3328] = (char) 0xffff; + data[3329] = (char) 0xffff; + data[3330] = (char) 0xffff; + data[3331] = (char) 0xffff; + data[3332] = (char) 0xffff; + data[3333] = (char) 0xffff; + data[3334] = (char) 0xffff; + data[3335] = (char) 0xffff; + data[3336] = (char) 0xffff; + data[3337] = (char) 0xffff; + data[3338] = (char) 0xffff; + data[3339] = (char) 0xffff; + data[3340] = (char) 0xffff; + data[3341] = (char) 0xffff; + data[3342] = (char) 0xffff; + data[3343] = (char) 0xffff; + data[3344] = (char) 0xffff; + data[3345] = (char) 0xffff; + data[3346] = (char) 0xffff; + data[3347] = (char) 0xffff; + data[3348] = (char) 0xffff; + data[3349] = (char) 0xffff; + data[3350] = (char) 0xffff; + data[3351] = (char) 0xffff; + data[3352] = (char) 0xffff; + data[3353] = (char) 0xffff; + data[3354] = (char) 0xffff; + data[3355] = (char) 0xffff; + data[3356] = (char) 0xffff; + data[3357] = (char) 0xffff; + data[3358] = (char) 0xffff; + data[3359] = (char) 0xffff; + data[3360] = (char) 0xffff; + data[3361] = (char) 0xffff; + data[3362] = (char) 0xffff; + data[3363] = (char) 0xffff; + data[3364] = (char) 0xffff; + data[3365] = (char) 0xffff; + data[3366] = (char) 0xffff; + data[3367] = (char) 0xffff; + data[3368] = (char) 0xffff; + data[3369] = (char) 0xffff; + data[3370] = (char) 0xffff; + data[3371] = (char) 0xffff; + data[3372] = (char) 0xffff; + data[3373] = (char) 0xffff; + data[3374] = (char) 0xffff; + data[3375] = (char) 0xffff; + data[3376] = (char) 0xffff; + data[3377] = (char) 0xffff; + data[3378] = (char) 0xffff; + data[3379] = (char) 0xffff; + data[3380] = (char) 0xffff; + data[3381] = (char) 0xffff; + data[3382] = (char) 0xffff; + data[3383] = (char) 0xffff; + data[3384] = (char) 0xffff; + data[3385] = (char) 0xffff; + data[3386] = (char) 0xffff; + data[3387] = (char) 0xffff; + data[3388] = (char) 0xffff; + data[3389] = (char) 0xffff; + data[3390] = (char) 0xffff; + data[3391] = (char) 0xffff; + data[3392] = (char) 0xffff; + data[3393] = (char) 0xffff; + data[3394] = (char) 0xffff; + data[3395] = (char) 0xffff; + data[3396] = (char) 0xffff; + data[3397] = (char) 0xffff; + data[3398] = (char) 0xffff; + data[3399] = (char) 0xffff; + data[3400] = (char) 0xffff; + data[3401] = (char) 0xffff; + data[3402] = (char) 0xffff; + data[3403] = (char) 0xffff; + data[3404] = (char) 0xffff; + data[3405] = (char) 0xffff; + data[3406] = (char) 0xffff; + data[3407] = (char) 0xffff; + data[3408] = (char) 0xffff; + data[3409] = (char) 0xffff; + data[3410] = (char) 0xffff; + data[3411] = (char) 0xffff; + data[3412] = (char) 0xffff; + data[3413] = (char) 0xffff; + data[3414] = (char) 0xffff; + data[3415] = (char) 0xffff; + data[3416] = (char) 0xffff; + data[3417] = (char) 0xffff; + data[3418] = (char) 0xffff; + data[3419] = (char) 0xffff; + data[3420] = (char) 0xffff; + data[3421] = (char) 0xffff; + data[3422] = (char) 0xffff; + data[3423] = (char) 0xffff; + data[3424] = (char) 0xffff; + data[3425] = (char) 0xffff; + data[3426] = (char) 0xffff; + data[3427] = (char) 0xffff; + data[3428] = (char) 0xffff; + data[3429] = (char) 0xffff; + data[3430] = (char) 0xffff; + data[3431] = (char) 0xffff; + data[3432] = (char) 0xffff; + data[3433] = (char) 0xffff; + data[3434] = (char) 0xffff; + data[3435] = (char) 0xffff; + data[3436] = (char) 0xffff; + data[3437] = (char) 0xffff; + data[3438] = (char) 0xffff; + data[3439] = (char) 0xffff; + data[3440] = (char) 0xffff; + data[3441] = (char) 0xffff; + data[3442] = (char) 0xffff; + data[3443] = (char) 0xffff; + data[3444] = (char) 0xffff; + data[3445] = (char) 0xffff; + data[3446] = (char) 0xffff; + data[3447] = (char) 0xffff; + data[3448] = (char) 0xffff; + data[3449] = (char) 0xffff; + data[3450] = (char) 0x000f; + data[3984] = (char) 0xffff; + data[3985] = (char) 0xffff; + data[3986] = (char) 0xffff; + data[3987] = (char) 0xffff; + data[3988] = (char) 0xffff; + data[3989] = (char) 0xffff; + data[3990] = (char) 0xffff; + data[3991] = (char) 0xffff; + data[3992] = (char) 0xffff; + data[3993] = (char) 0xffff; + data[3994] = (char) 0xffff; + data[3995] = (char) 0xffff; + data[3996] = (char) 0xffff; + data[3997] = (char) 0xffff; + data[3998] = (char) 0xffff; + data[3999] = (char) 0xffff; + data[4000] = (char) 0xffff; + data[4001] = (char) 0xffff; + data[4002] = (char) 0x3fff; + data[4016] = (char) 0x007f; + data[4017] = (char) 0x80f8; + data[4018] = (char) 0xfdff; + data[4019] = (char) 0x5f7f; + data[4020] = (char) 0xffdb; + data[4021] = (char) 0xffff; + data[4022] = (char) 0xffff; + data[4023] = (char) 0xffff; + data[4024] = (char) 0xffff; + data[4025] = (char) 0xffff; + data[4026] = (char) 0xffff; + data[4027] = (char) 0x0003; + data[4029] = (char) 0xfff8; + data[4030] = (char) 0xffff; + data[4031] = (char) 0xffff; + data[4032] = (char) 0xffff; + data[4033] = (char) 0xffff; + data[4034] = (char) 0xffff; + data[4035] = (char) 0xffff; + data[4036] = (char) 0xffff; + data[4037] = (char) 0xffff; + data[4038] = (char) 0xffff; + data[4039] = (char) 0xffff; + data[4040] = (char) 0xffff; + data[4041] = (char) 0xffff; + data[4042] = (char) 0xffff; + data[4043] = (char) 0xffff; + data[4044] = (char) 0xffff; + data[4045] = (char) 0xffff; + data[4046] = (char) 0xffff; + data[4047] = (char) 0xffff; + data[4048] = (char) 0xffff; + data[4049] = (char) 0xffff; + data[4050] = (char) 0xffff; + data[4051] = (char) 0x3fff; + data[4053] = (char) 0xffff; + data[4054] = (char) 0xffff; + data[4055] = (char) 0xffff; + data[4056] = (char) 0xffff; + data[4057] = (char) 0xfffc; + data[4058] = (char) 0xffff; + data[4059] = (char) 0xffff; + data[4060] = (char) 0x00ff; + data[4063] = (char) 0x0fff; + data[4071] = (char) 0xffd7; + data[4072] = (char) 0xffff; + data[4073] = (char) 0xffff; + data[4074] = (char) 0xffff; + data[4075] = (char) 0xffff; + data[4076] = (char) 0xffff; + data[4077] = (char) 0xffff; + data[4078] = (char) 0xffff; + data[4079] = (char) 0x1fff; + data[4082] = (char) 0xfffe; + data[4083] = (char) 0x07ff; + data[4084] = (char) 0xfffe; + data[4085] = (char) 0x07ff; + data[4086] = (char) 0xffc0; + data[4087] = (char) 0xffff; + data[4088] = (char) 0xffff; + data[4089] = (char) 0xffff; + data[4090] = (char) 0xffff; + data[4091] = (char) 0x7fff; + data[4092] = (char) 0xfcfc; + data[4093] = (char) 0x1cfc; + data[4100] = (char) 0xfffe; + data[4101] = (char) 0x07ff; + data[4102] = (char) 0xfffe; + data[4103] = (char) 0x07ff; + data[4106] = (char) 0x0400; + data[4107] = (char) 0x0420; + data[4108] = (char) 0xffff; + data[4109] = (char) 0xff7f; + data[4110] = (char) 0xffff; + data[4111] = (char) 0xff7f; + data[4112] = (char) 0xffff; + data[4113] = (char) 0xffff; + data[4114] = (char) 0xffff; + data[4115] = (char) 0xffff; + data[4116] = (char) 0xffff; + data[4117] = (char) 0xffff; + data[4118] = (char) 0xffff; + data[4119] = (char) 0xffff; + data[4120] = (char) 0xffff; + data[4121] = (char) 0xffff; + data[4122] = (char) 0xffff; + data[4123] = (char) 0xffff; + data[4124] = (char) 0xffff; + data[4125] = (char) 0xffff; + data[4126] = (char) 0xffff; + data[4127] = (char) 0xfc3f; + data[4128] = (char) 0xffff; + data[4129] = (char) 0x00ff; + data[4133] = (char) 0xffff; + data[4134] = (char) 0xffff; + data[4135] = (char) 0xffff; + data[4136] = (char) 0xffff; + data[4137] = (char) 0xffff; + data[4138] = (char) 0x01ff; + data[4139] = (char) 0xf9ff; + data[4140] = (char) 0x0003; + data[4141] = (char) 0x0003; + data[4142] = (char) 0x001f; + data[4151] = (char) 0x0400; + data[4152] = (char) 0xd740; + data[4153] = (char) 0xffff; + data[4154] = (char) 0xfffb; + data[4155] = (char) 0xffff; + data[4156] = (char) 0x7fff; + data[4157] = (char) 0x547f; + data[4158] = (char) 0x00fd; } + public static Bits white; - static void white_f() { + static void white_f() + { char[] data = new char[4159]; white = new Bits(data); - data[0]=(char)0x3e00; - data[1]=(char)0xf000; - data[2]=(char)0x0001; - data[512]=(char)0x0fff; - data[514]=(char)0x0300; - data[768]=(char)0x0001; - data[4096]=(char)0x3e00; - data[4097]=(char)0xf000; - data[4098]=(char)0x0001; + data[0] = (char) 0x3e00; + data[1] = (char) 0xf000; + data[2] = (char) 0x0001; + data[512] = (char) 0x0fff; + data[514] = (char) 0x0300; + data[768] = (char) 0x0001; + data[4096] = (char) 0x3e00; + data[4097] = (char) 0xf000; + data[4098] = (char) 0x0001; } + public static Bits punct; - static void punct_f() { + static void punct_f() + { char[] data = new char[4159]; punct = new Bits(data); - data[2]=(char)0xf7ee; - data[3]=(char)0x8c00; - data[4]=(char)0x0001; - data[5]=(char)0xb800; - data[7]=(char)0x2800; - data[10]=(char)0x2802; - data[11]=(char)0x8880; - data[55]=(char)0x4030; - data[56]=(char)0x0080; - data[85]=(char)0xfc00; - data[88]=(char)0x0200; - data[91]=(char)0x4000; - data[92]=(char)0x0009; - data[95]=(char)0x0018; - data[96]=(char)0x1000; - data[97]=(char)0x8800; - data[102]=(char)0x3c00; - data[109]=(char)0x0010; - data[150]=(char)0x0030; - data[151]=(char)0x0001; - data[226]=(char)0x8000; - data[229]=(char)0x0c00; - data[234]=(char)0x8000; - data[240]=(char)0xfff0; - data[241]=(char)0x0007; - data[243]=(char)0x3c00; - data[248]=(char)0x0020; - data[271]=(char)0x0800; - data[513]=(char)0xffff; - data[514]=(char)0x00ff; - data[515]=(char)0xffff; - data[516]=(char)0x006f; - data[519]=(char)0x6000; - data[520]=(char)0x6000; - data[562]=(char)0x0600; - data[768]=(char)0xff4e; - data[769]=(char)0xfff3; - data[771]=(char)0x0001; - data[783]=(char)0x0800; - data[4051]=(char)0xc000; - data[4067]=(char)0xffff; - data[4068]=(char)0xfe1f; - data[4069]=(char)0xfff7; - data[4070]=(char)0x0d0b; - data[4080]=(char)0xf7ee; - data[4081]=(char)0x8c00; - data[4082]=(char)0x0001; - data[4083]=(char)0xb800; - data[4085]=(char)0x2800; - data[4086]=(char)0x003e; - data[4098]=(char)0xf7ee; - data[4099]=(char)0x8c00; - data[4100]=(char)0x0001; - data[4101]=(char)0xb800; - data[4103]=(char)0x2800; - data[4106]=(char)0x2802; - data[4107]=(char)0x8880; - data[4151]=(char)0x4030; - data[4152]=(char)0x0080; + data[2] = (char) 0xf7ee; + data[3] = (char) 0x8c00; + data[4] = (char) 0x0001; + data[5] = (char) 0xb800; + data[7] = (char) 0x2800; + data[10] = (char) 0x2802; + data[11] = (char) 0x8880; + data[55] = (char) 0x4030; + data[56] = (char) 0x0080; + data[85] = (char) 0xfc00; + data[88] = (char) 0x0200; + data[91] = (char) 0x4000; + data[92] = (char) 0x0009; + data[95] = (char) 0x0018; + data[96] = (char) 0x1000; + data[97] = (char) 0x8800; + data[102] = (char) 0x3c00; + data[109] = (char) 0x0010; + data[150] = (char) 0x0030; + data[151] = (char) 0x0001; + data[226] = (char) 0x8000; + data[229] = (char) 0x0c00; + data[234] = (char) 0x8000; + data[240] = (char) 0xfff0; + data[241] = (char) 0x0007; + data[243] = (char) 0x3c00; + data[248] = (char) 0x0020; + data[271] = (char) 0x0800; + data[513] = (char) 0xffff; + data[514] = (char) 0x00ff; + data[515] = (char) 0xffff; + data[516] = (char) 0x006f; + data[519] = (char) 0x6000; + data[520] = (char) 0x6000; + data[562] = (char) 0x0600; + data[768] = (char) 0xff4e; + data[769] = (char) 0xfff3; + data[771] = (char) 0x0001; + data[783] = (char) 0x0800; + data[4051] = (char) 0xc000; + data[4067] = (char) 0xffff; + data[4068] = (char) 0xfe1f; + data[4069] = (char) 0xfff7; + data[4070] = (char) 0x0d0b; + data[4080] = (char) 0xf7ee; + data[4081] = (char) 0x8c00; + data[4082] = (char) 0x0001; + data[4083] = (char) 0xb800; + data[4085] = (char) 0x2800; + data[4086] = (char) 0x003e; + data[4098] = (char) 0xf7ee; + data[4099] = (char) 0x8c00; + data[4100] = (char) 0x0001; + data[4101] = (char) 0xb800; + data[4103] = (char) 0x2800; + data[4106] = (char) 0x2802; + data[4107] = (char) 0x8880; + data[4151] = (char) 0x4030; + data[4152] = (char) 0x0080; } } diff --git a/src/com/stevesoft/pat/Boundary.java b/src/com/stevesoft/pat/Boundary.java index 959bb04..d6481b4 100755 --- a/src/com/stevesoft/pat/Boundary.java +++ b/src/com/stevesoft/pat/Boundary.java @@ -6,46 +6,87 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** This class implements the word boundary pattern element: \b. */ -class Boundary extends Pattern { - public String toString() { - return "\\b"+nextString(); - } - boolean isAChar(char c) { - if(c >= 'a' && c <= 'z') - return true; - if(c >= 'A' && c <= 'Z') - return true; - if(c >= '0' && c <= '9') - return true; - if(c == '_') - return true; - return false; - } - boolean matchLeft(int pos,Pthings pt) { - if(pos <= 0) - return true; - if(isAChar(pt.src.charAt(pos)) - && isAChar(pt.src.charAt(pos-1))) - return false; - return true; - } - boolean matchRight(int pos,Pthings pt) { - if(pos < 0) return false; - if(pos+1 >= pt.src.length()) - return true; - if(isAChar(pt.src.charAt(pos)) - && isAChar(pt.src.charAt(pos+1))) - return false; - return true; - } - public int matchInternal(int pos,Pthings pt) { - if(matchRight(pos-1,pt) || matchLeft(pos,pt)) - return nextMatch(pos,pt); - return -1; - } - public patInt maxChars() { return new patInt(0); } - public Pattern clone1(Hashtable h) { return new Boundary(); } +class Boundary + extends Pattern +{ + public String toString() + { + return "\\b" + nextString(); + } + + boolean isAChar(char c) + { + if (c >= 'a' && c <= 'z') + { + return true; + } + if (c >= 'A' && c <= 'Z') + { + return true; + } + if (c >= '0' && c <= '9') + { + return true; + } + if (c == '_') + { + return true; + } + return false; + } + + boolean matchLeft(int pos, Pthings pt) + { + if (pos <= 0) + { + return true; + } + if (isAChar(pt.src.charAt(pos)) + && isAChar(pt.src.charAt(pos - 1))) + { + return false; + } + return true; + } + + boolean matchRight(int pos, Pthings pt) + { + if (pos < 0) + { + return false; + } + if (pos + 1 >= pt.src.length()) + { + return true; + } + if (isAChar(pt.src.charAt(pos)) + && isAChar(pt.src.charAt(pos + 1))) + { + return false; + } + return true; + } + + public int matchInternal(int pos, Pthings pt) + { + if (matchRight(pos - 1, pt) || matchLeft(pos, pt)) + { + return nextMatch(pos, pt); + } + return -1; + } + + public patInt maxChars() + { + return new patInt(0); + } + + public Pattern clone1(Hashtable h) + { + return new Boundary(); + } }; diff --git a/src/com/stevesoft/pat/Bracket.java b/src/com/stevesoft/pat/Bracket.java index 9f60179..175731b 100755 --- a/src/com/stevesoft/pat/Bracket.java +++ b/src/com/stevesoft/pat/Bracket.java @@ -6,43 +6,82 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Vector; -import java.util.Hashtable; + +import java.util.*; /** The Bracket is a form of the Or class, implements the pattern element [ ]. */ -class Bracket extends Or { - boolean neg; - Bracket(boolean n) { neg = n; } - String leftForm() { - if(neg) - return "[^"; - else - return "["; +class Bracket + extends Or +{ + boolean neg; + Bracket(boolean n) + { + neg = n; + } + + String leftForm() + { + if (neg) + { + return "[^"; + } + else + { + return "["; } - String rightForm() { return "]"; } - String sepForm() { return ""; } - public int matchInternal(int pos,Pthings pt) { - if(pos >= pt.src.length()) return -1; - int r = super.matchInternal(pos,pt); - if((neg && r<0)||(!neg && r>=0)) - return nextMatch(pos+1,pt); - return -1; + } + + String rightForm() + { + return "]"; + } + + String sepForm() + { + return ""; + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length()) + { + return -1; } - public patInt minChars() { return new patInt(1); } - public patInt maxChars() { return new patInt(1); } - - public Or addOr(Pattern p) { - pv = null; - v.addElement(p); - p.setParent(null); - return this; + int r = super.matchInternal(pos, pt); + if ( (neg && r < 0) || (!neg && r >= 0)) + { + return nextMatch(pos + 1, pt); } - public Pattern clone1(Hashtable h) { - Bracket b = new Bracket(neg); - b.v = new Vector(); - for(int i=0;i s2.length() || i1 + i3 > s1.length()) + { + return false; } - /** Convert a character to lower case. */ - public static char toLowerCase(char c) { - if(java_1_0) { - int ret = (int)c; - switch(c) { - case 65: ret=97; break; - case 66: ret=98; break; - case 67: ret=99; break; - case 68: ret=100; break; - case 69: ret=101; break; - case 70: ret=102; break; - case 71: ret=103; break; - case 72: ret=104; break; - case 73: ret=105; break; - case 74: ret=106; break; - case 75: ret=107; break; - case 76: ret=108; break; - case 77: ret=109; break; - case 78: ret=110; break; - case 79: ret=111; break; - case 80: ret=112; break; - case 81: ret=113; break; - case 82: ret=114; break; - case 83: ret=115; break; - case 84: ret=116; break; - case 85: ret=117; break; - case 86: ret=118; break; - case 87: ret=119; break; - case 88: ret=120; break; - case 89: ret=121; break; - case 90: ret=122; break; - case 192: ret=224; break; - case 193: ret=225; break; - case 194: ret=226; break; - case 195: ret=227; break; - case 196: ret=228; break; - case 197: ret=229; break; - case 198: ret=230; break; - case 199: ret=231; break; - case 200: ret=232; break; - case 201: ret=233; break; - case 202: ret=234; break; - case 203: ret=235; break; - case 204: ret=236; break; - case 205: ret=237; break; - case 206: ret=238; break; - case 207: ret=239; break; - case 208: ret=240; break; - case 209: ret=241; break; - case 210: ret=242; break; - case 211: ret=243; break; - case 212: ret=244; break; - case 213: ret=245; break; - case 214: ret=246; break; - case 216: ret=248; break; - case 217: ret=249; break; - case 218: ret=250; break; - case 219: ret=251; break; - case 220: ret=252; break; - case 221: ret=253; break; - case 222: ret=254; break; - case 256: ret=257; break; - case 258: ret=259; break; - case 260: ret=261; break; - case 262: ret=263; break; - case 264: ret=265; break; - case 266: ret=267; break; - case 268: ret=269; break; - case 270: ret=271; break; - case 272: ret=273; break; - case 274: ret=275; break; - case 276: ret=277; break; - case 278: ret=279; break; - case 280: ret=281; break; - case 282: ret=283; break; - case 284: ret=285; break; - case 286: ret=287; break; - case 288: ret=289; break; - case 290: ret=291; break; - case 292: ret=293; break; - case 294: ret=295; break; - case 296: ret=297; break; - case 298: ret=299; break; - case 300: ret=301; break; - case 302: ret=303; break; - case 304: ret=105; break; - case 306: ret=307; break; - case 308: ret=309; break; - case 310: ret=311; break; - case 313: ret=314; break; - case 315: ret=316; break; - case 317: ret=318; break; - case 319: ret=320; break; - case 321: ret=322; break; - case 323: ret=324; break; - case 325: ret=326; break; - case 327: ret=328; break; - case 330: ret=331; break; - case 332: ret=333; break; - case 334: ret=335; break; - case 336: ret=337; break; - case 338: ret=339; break; - case 340: ret=341; break; - case 342: ret=343; break; - case 344: ret=345; break; - case 346: ret=347; break; - case 348: ret=349; break; - case 350: ret=351; break; - case 352: ret=353; break; - case 354: ret=355; break; - case 356: ret=357; break; - case 358: ret=359; break; - case 360: ret=361; break; - case 362: ret=363; break; - case 364: ret=365; break; - case 366: ret=367; break; - case 368: ret=369; break; - case 370: ret=371; break; - case 372: ret=373; break; - case 374: ret=375; break; - case 376: ret=255; break; - case 377: ret=378; break; - case 379: ret=380; break; - case 381: ret=382; break; - case 385: ret=595; break; - case 386: ret=387; break; - case 388: ret=389; break; - case 390: ret=596; break; - case 391: ret=392; break; - case 393: ret=598; break; - case 394: ret=599; break; - case 395: ret=396; break; - case 398: ret=600; break; - case 399: ret=601; break; - case 400: ret=603; break; - case 401: ret=402; break; - case 403: ret=608; break; - case 404: ret=611; break; - case 406: ret=617; break; - case 407: ret=616; break; - case 408: ret=409; break; - case 412: ret=623; break; - case 413: ret=626; break; - case 416: ret=417; break; - case 418: ret=419; break; - case 420: ret=421; break; - case 423: ret=424; break; - case 425: ret=643; break; - case 428: ret=429; break; - case 430: ret=648; break; - case 431: ret=432; break; - case 433: ret=650; break; - case 434: ret=651; break; - case 435: ret=436; break; - case 437: ret=438; break; - case 439: ret=658; break; - case 440: ret=441; break; - case 444: ret=445; break; - case 452: ret=454; break; - case 453: ret=454; break; - case 455: ret=457; break; - case 456: ret=457; break; - case 458: ret=460; break; - case 459: ret=460; break; - case 461: ret=462; break; - case 463: ret=464; break; - case 465: ret=466; break; - case 467: ret=468; break; - case 469: ret=470; break; - case 471: ret=472; break; - case 473: ret=474; break; - case 475: ret=476; break; - case 478: ret=479; break; - case 480: ret=481; break; - case 482: ret=483; break; - case 484: ret=485; break; - case 486: ret=487; break; - case 488: ret=489; break; - case 490: ret=491; break; - case 492: ret=493; break; - case 494: ret=495; break; - case 497: ret=499; break; - case 498: ret=499; break; - case 500: ret=501; break; - case 506: ret=507; break; - case 508: ret=509; break; - case 510: ret=511; break; - case 512: ret=513; break; - case 514: ret=515; break; - case 516: ret=517; break; - case 518: ret=519; break; - case 520: ret=521; break; - case 522: ret=523; break; - case 524: ret=525; break; - case 526: ret=527; break; - case 528: ret=529; break; - case 530: ret=531; break; - case 532: ret=533; break; - case 534: ret=535; break; - case 902: ret=940; break; - case 904: ret=941; break; - case 905: ret=942; break; - case 906: ret=943; break; - case 908: ret=972; break; - case 910: ret=973; break; - case 911: ret=974; break; - case 913: ret=945; break; - case 914: ret=946; break; - case 915: ret=947; break; - case 916: ret=948; break; - case 917: ret=949; break; - case 918: ret=950; break; - case 919: ret=951; break; - case 920: ret=952; break; - case 921: ret=953; break; - case 922: ret=954; break; - case 923: ret=955; break; - case 924: ret=956; break; - case 925: ret=957; break; - case 926: ret=958; break; - case 927: ret=959; break; - case 928: ret=960; break; - case 929: ret=961; break; - case 931: ret=963; break; - case 932: ret=964; break; - case 933: ret=965; break; - case 934: ret=966; break; - case 935: ret=967; break; - case 936: ret=968; break; - case 937: ret=969; break; - case 938: ret=970; break; - case 939: ret=971; break; - case 994: ret=995; break; - case 996: ret=997; break; - case 998: ret=999; break; - case 1000: ret=1001; break; - case 1002: ret=1003; break; - case 1004: ret=1005; break; - case 1006: ret=1007; break; - case 1025: ret=1105; break; - case 1026: ret=1106; break; - case 1027: ret=1107; break; - case 1028: ret=1108; break; - case 1029: ret=1109; break; - case 1030: ret=1110; break; - case 1031: ret=1111; break; - case 1032: ret=1112; break; - case 1033: ret=1113; break; - case 1034: ret=1114; break; - case 1035: ret=1115; break; - case 1036: ret=1116; break; - case 1038: ret=1118; break; - case 1039: ret=1119; break; - case 1040: ret=1072; break; - case 1041: ret=1073; break; - case 1042: ret=1074; break; - case 1043: ret=1075; break; - case 1044: ret=1076; break; - case 1045: ret=1077; break; - case 1046: ret=1078; break; - case 1047: ret=1079; break; - case 1048: ret=1080; break; - case 1049: ret=1081; break; - case 1050: ret=1082; break; - case 1051: ret=1083; break; - case 1052: ret=1084; break; - case 1053: ret=1085; break; - case 1054: ret=1086; break; - case 1055: ret=1087; break; - case 1056: ret=1088; break; - case 1057: ret=1089; break; - case 1058: ret=1090; break; - case 1059: ret=1091; break; - case 1060: ret=1092; break; - case 1061: ret=1093; break; - case 1062: ret=1094; break; - case 1063: ret=1095; break; - case 1064: ret=1096; break; - case 1065: ret=1097; break; - case 1066: ret=1098; break; - case 1067: ret=1099; break; - case 1068: ret=1100; break; - case 1069: ret=1101; break; - case 1070: ret=1102; break; - case 1071: ret=1103; break; - case 1120: ret=1121; break; - case 1122: ret=1123; break; - case 1124: ret=1125; break; - case 1126: ret=1127; break; - case 1128: ret=1129; break; - case 1130: ret=1131; break; - case 1132: ret=1133; break; - case 1134: ret=1135; break; - case 1136: ret=1137; break; - case 1138: ret=1139; break; - case 1140: ret=1141; break; - case 1142: ret=1143; break; - case 1144: ret=1145; break; - case 1146: ret=1147; break; - case 1148: ret=1149; break; - case 1150: ret=1151; break; - case 1152: ret=1153; break; - case 1168: ret=1169; break; - case 1170: ret=1171; break; - case 1172: ret=1173; break; - case 1174: ret=1175; break; - case 1176: ret=1177; break; - case 1178: ret=1179; break; - case 1180: ret=1181; break; - case 1182: ret=1183; break; - case 1184: ret=1185; break; - case 1186: ret=1187; break; - case 1188: ret=1189; break; - case 1190: ret=1191; break; - case 1192: ret=1193; break; - case 1194: ret=1195; break; - case 1196: ret=1197; break; - case 1198: ret=1199; break; - case 1200: ret=1201; break; - case 1202: ret=1203; break; - case 1204: ret=1205; break; - case 1206: ret=1207; break; - case 1208: ret=1209; break; - case 1210: ret=1211; break; - case 1212: ret=1213; break; - case 1214: ret=1215; break; - case 1217: ret=1218; break; - case 1219: ret=1220; break; - case 1223: ret=1224; break; - case 1227: ret=1228; break; - case 1232: ret=1233; break; - case 1234: ret=1235; break; - case 1236: ret=1237; break; - case 1238: ret=1239; break; - case 1240: ret=1241; break; - case 1242: ret=1243; break; - case 1244: ret=1245; break; - case 1246: ret=1247; break; - case 1248: ret=1249; break; - case 1250: ret=1251; break; - case 1252: ret=1253; break; - case 1254: ret=1255; break; - case 1256: ret=1257; break; - case 1258: ret=1259; break; - case 1262: ret=1263; break; - case 1264: ret=1265; break; - case 1266: ret=1267; break; - case 1268: ret=1269; break; - case 1272: ret=1273; break; - case 1329: ret=1377; break; - case 1330: ret=1378; break; - case 1331: ret=1379; break; - case 1332: ret=1380; break; - case 1333: ret=1381; break; - case 1334: ret=1382; break; - case 1335: ret=1383; break; - case 1336: ret=1384; break; - case 1337: ret=1385; break; - case 1338: ret=1386; break; - case 1339: ret=1387; break; - case 1340: ret=1388; break; - case 1341: ret=1389; break; - case 1342: ret=1390; break; - case 1343: ret=1391; break; - case 1344: ret=1392; break; - case 1345: ret=1393; break; - case 1346: ret=1394; break; - case 1347: ret=1395; break; - case 1348: ret=1396; break; - case 1349: ret=1397; break; - case 1350: ret=1398; break; - case 1351: ret=1399; break; - case 1352: ret=1400; break; - case 1353: ret=1401; break; - case 1354: ret=1402; break; - case 1355: ret=1403; break; - case 1356: ret=1404; break; - case 1357: ret=1405; break; - case 1358: ret=1406; break; - case 1359: ret=1407; break; - case 1360: ret=1408; break; - case 1361: ret=1409; break; - case 1362: ret=1410; break; - case 1363: ret=1411; break; - case 1364: ret=1412; break; - case 1365: ret=1413; break; - case 1366: ret=1414; break; - case 4256: ret=4304; break; - case 4257: ret=4305; break; - case 4258: ret=4306; break; - case 4259: ret=4307; break; - case 4260: ret=4308; break; - case 4261: ret=4309; break; - case 4262: ret=4310; break; - case 4263: ret=4311; break; - case 4264: ret=4312; break; - case 4265: ret=4313; break; - case 4266: ret=4314; break; - case 4267: ret=4315; break; - case 4268: ret=4316; break; - case 4269: ret=4317; break; - case 4270: ret=4318; break; - case 4271: ret=4319; break; - case 4272: ret=4320; break; - case 4273: ret=4321; break; - case 4274: ret=4322; break; - case 4275: ret=4323; break; - case 4276: ret=4324; break; - case 4277: ret=4325; break; - case 4278: ret=4326; break; - case 4279: ret=4327; break; - case 4280: ret=4328; break; - case 4281: ret=4329; break; - case 4282: ret=4330; break; - case 4283: ret=4331; break; - case 4284: ret=4332; break; - case 4285: ret=4333; break; - case 4286: ret=4334; break; - case 4287: ret=4335; break; - case 4288: ret=4336; break; - case 4289: ret=4337; break; - case 4290: ret=4338; break; - case 4291: ret=4339; break; - case 4292: ret=4340; break; - case 4293: ret=4341; break; - case 7680: ret=7681; break; - case 7682: ret=7683; break; - case 7684: ret=7685; break; - case 7686: ret=7687; break; - case 7688: ret=7689; break; - case 7690: ret=7691; break; - case 7692: ret=7693; break; - case 7694: ret=7695; break; - case 7696: ret=7697; break; - case 7698: ret=7699; break; - case 7700: ret=7701; break; - case 7702: ret=7703; break; - case 7704: ret=7705; break; - case 7706: ret=7707; break; - case 7708: ret=7709; break; - case 7710: ret=7711; break; - case 7712: ret=7713; break; - case 7714: ret=7715; break; - case 7716: ret=7717; break; - case 7718: ret=7719; break; - case 7720: ret=7721; break; - case 7722: ret=7723; break; - case 7724: ret=7725; break; - case 7726: ret=7727; break; - case 7728: ret=7729; break; - case 7730: ret=7731; break; - case 7732: ret=7733; break; - case 7734: ret=7735; break; - case 7736: ret=7737; break; - case 7738: ret=7739; break; - case 7740: ret=7741; break; - case 7742: ret=7743; break; - case 7744: ret=7745; break; - case 7746: ret=7747; break; - case 7748: ret=7749; break; - case 7750: ret=7751; break; - case 7752: ret=7753; break; - case 7754: ret=7755; break; - case 7756: ret=7757; break; - case 7758: ret=7759; break; - case 7760: ret=7761; break; - case 7762: ret=7763; break; - case 7764: ret=7765; break; - case 7766: ret=7767; break; - case 7768: ret=7769; break; - case 7770: ret=7771; break; - case 7772: ret=7773; break; - case 7774: ret=7775; break; - case 7776: ret=7777; break; - case 7778: ret=7779; break; - case 7780: ret=7781; break; - case 7782: ret=7783; break; - case 7784: ret=7785; break; - case 7786: ret=7787; break; - case 7788: ret=7789; break; - case 7790: ret=7791; break; - case 7792: ret=7793; break; - case 7794: ret=7795; break; - case 7796: ret=7797; break; - case 7798: ret=7799; break; - case 7800: ret=7801; break; - case 7802: ret=7803; break; - case 7804: ret=7805; break; - case 7806: ret=7807; break; - case 7808: ret=7809; break; - case 7810: ret=7811; break; - case 7812: ret=7813; break; - case 7814: ret=7815; break; - case 7816: ret=7817; break; - case 7818: ret=7819; break; - case 7820: ret=7821; break; - case 7822: ret=7823; break; - case 7824: ret=7825; break; - case 7826: ret=7827; break; - case 7828: ret=7829; break; - case 7840: ret=7841; break; - case 7842: ret=7843; break; - case 7844: ret=7845; break; - case 7846: ret=7847; break; - case 7848: ret=7849; break; - case 7850: ret=7851; break; - case 7852: ret=7853; break; - case 7854: ret=7855; break; - case 7856: ret=7857; break; - case 7858: ret=7859; break; - case 7860: ret=7861; break; - case 7862: ret=7863; break; - case 7864: ret=7865; break; - case 7866: ret=7867; break; - case 7868: ret=7869; break; - case 7870: ret=7871; break; - case 7872: ret=7873; break; - case 7874: ret=7875; break; - case 7876: ret=7877; break; - case 7878: ret=7879; break; - case 7880: ret=7881; break; - case 7882: ret=7883; break; - case 7884: ret=7885; break; - case 7886: ret=7887; break; - case 7888: ret=7889; break; - case 7890: ret=7891; break; - case 7892: ret=7893; break; - case 7894: ret=7895; break; - case 7896: ret=7897; break; - case 7898: ret=7899; break; - case 7900: ret=7901; break; - case 7902: ret=7903; break; - case 7904: ret=7905; break; - case 7906: ret=7907; break; - case 7908: ret=7909; break; - case 7910: ret=7911; break; - case 7912: ret=7913; break; - case 7914: ret=7915; break; - case 7916: ret=7917; break; - case 7918: ret=7919; break; - case 7920: ret=7921; break; - case 7922: ret=7923; break; - case 7924: ret=7925; break; - case 7926: ret=7927; break; - case 7928: ret=7929; break; - case 7944: ret=7936; break; - case 7945: ret=7937; break; - case 7946: ret=7938; break; - case 7947: ret=7939; break; - case 7948: ret=7940; break; - case 7949: ret=7941; break; - case 7950: ret=7942; break; - case 7951: ret=7943; break; - case 7960: ret=7952; break; - case 7961: ret=7953; break; - case 7962: ret=7954; break; - case 7963: ret=7955; break; - case 7964: ret=7956; break; - case 7965: ret=7957; break; - case 7976: ret=7968; break; - case 7977: ret=7969; break; - case 7978: ret=7970; break; - case 7979: ret=7971; break; - case 7980: ret=7972; break; - case 7981: ret=7973; break; - case 7982: ret=7974; break; - case 7983: ret=7975; break; - case 7992: ret=7984; break; - case 7993: ret=7985; break; - case 7994: ret=7986; break; - case 7995: ret=7987; break; - case 7996: ret=7988; break; - case 7997: ret=7989; break; - case 7998: ret=7990; break; - case 7999: ret=7991; break; - case 8008: ret=8000; break; - case 8009: ret=8001; break; - case 8010: ret=8002; break; - case 8011: ret=8003; break; - case 8012: ret=8004; break; - case 8013: ret=8005; break; - case 8025: ret=8017; break; - case 8027: ret=8019; break; - case 8029: ret=8021; break; - case 8031: ret=8023; break; - case 8040: ret=8032; break; - case 8041: ret=8033; break; - case 8042: ret=8034; break; - case 8043: ret=8035; break; - case 8044: ret=8036; break; - case 8045: ret=8037; break; - case 8046: ret=8038; break; - case 8047: ret=8039; break; - case 8072: ret=8064; break; - case 8073: ret=8065; break; - case 8074: ret=8066; break; - case 8075: ret=8067; break; - case 8076: ret=8068; break; - case 8077: ret=8069; break; - case 8078: ret=8070; break; - case 8079: ret=8071; break; - case 8088: ret=8080; break; - case 8089: ret=8081; break; - case 8090: ret=8082; break; - case 8091: ret=8083; break; - case 8092: ret=8084; break; - case 8093: ret=8085; break; - case 8094: ret=8086; break; - case 8095: ret=8087; break; - case 8104: ret=8096; break; - case 8105: ret=8097; break; - case 8106: ret=8098; break; - case 8107: ret=8099; break; - case 8108: ret=8100; break; - case 8109: ret=8101; break; - case 8110: ret=8102; break; - case 8111: ret=8103; break; - case 8120: ret=8112; break; - case 8121: ret=8113; break; - case 8122: ret=8048; break; - case 8123: ret=8049; break; - case 8124: ret=8115; break; - case 8136: ret=8050; break; - case 8137: ret=8051; break; - case 8138: ret=8052; break; - case 8139: ret=8053; break; - case 8140: ret=8131; break; - case 8152: ret=8144; break; - case 8153: ret=8145; break; - case 8154: ret=8054; break; - case 8155: ret=8055; break; - case 8168: ret=8160; break; - case 8169: ret=8161; break; - case 8170: ret=8058; break; - case 8171: ret=8059; break; - case 8172: ret=8165; break; - case 8184: ret=8056; break; - case 8185: ret=8057; break; - case 8186: ret=8060; break; - case 8187: ret=8061; break; - case 8188: ret=8179; break; - case 8544: ret=8560; break; - case 8545: ret=8561; break; - case 8546: ret=8562; break; - case 8547: ret=8563; break; - case 8548: ret=8564; break; - case 8549: ret=8565; break; - case 8550: ret=8566; break; - case 8551: ret=8567; break; - case 8552: ret=8568; break; - case 8553: ret=8569; break; - case 8554: ret=8570; break; - case 8555: ret=8571; break; - case 8556: ret=8572; break; - case 8557: ret=8573; break; - case 8558: ret=8574; break; - case 8559: ret=8575; break; - case 9398: ret=9424; break; - case 9399: ret=9425; break; - case 9400: ret=9426; break; - case 9401: ret=9427; break; - case 9402: ret=9428; break; - case 9403: ret=9429; break; - case 9404: ret=9430; break; - case 9405: ret=9431; break; - case 9406: ret=9432; break; - case 9407: ret=9433; break; - case 9408: ret=9434; break; - case 9409: ret=9435; break; - case 9410: ret=9436; break; - case 9411: ret=9437; break; - case 9412: ret=9438; break; - case 9413: ret=9439; break; - case 9414: ret=9440; break; - case 9415: ret=9441; break; - case 9416: ret=9442; break; - case 9417: ret=9443; break; - case 9418: ret=9444; break; - case 9419: ret=9445; break; - case 9420: ret=9446; break; - case 9421: ret=9447; break; - case 9422: ret=9448; break; - case 9423: ret=9449; break; - case 65313: ret=65345; break; - case 65314: ret=65346; break; - case 65315: ret=65347; break; - case 65316: ret=65348; break; - case 65317: ret=65349; break; - case 65318: ret=65350; break; - case 65319: ret=65351; break; - case 65320: ret=65352; break; - case 65321: ret=65353; break; - case 65322: ret=65354; break; - case 65323: ret=65355; break; - case 65324: ret=65356; break; - case 65325: ret=65357; break; - case 65326: ret=65358; break; - case 65327: ret=65359; break; - case 65328: ret=65360; break; - case 65329: ret=65361; break; - case 65330: ret=65362; break; - case 65331: ret=65363; break; - case 65332: ret=65364; break; - case 65333: ret=65365; break; - case 65334: ret=65366; break; - case 65335: ret=65367; break; - case 65336: ret=65368; break; - case 65337: ret=65369; break; - case 65338: ret=65370; break; + if (!ign) + { + for (int i = i2; i < itot; i++) + { + if (s2.charAt(i) != s1.charAt(i1++)) + { + return false; } - return (char)ret; } - return Character.toLowerCase(c); } - /** Convert a String to title case. */ - public static String toTitleCase(String s) { - StringBuffer sb = new StringBuffer(); - for(int i=0;i s2.length() || i1 + i3 > s1.length()) + { + return false; } - /** Convert a String to lower case. */ - public static String toLowerCase(String s) { - StringBuffer sb = new StringBuffer(); - for(int i=0;is2.length()||i1+i3>s1.length()) return false; - if(!ign) { - for(int i=i2;i s2.length() || i1 + i3 > s1.length()) + { + return false; + } + if (!ign) + { + for (int i = i2; i < itot; i++) + { + if (s2.charAt(i) != s1.charAt(i1++)) + { + return false; } - return true; + } } - /** Duplicates the regionMatches routine of String -- but - makes use of the definitions of upper, lower, and title - case in this class when ignoreCase is set. */ - public static boolean regionMatches( String s1, - boolean ign,int i1,StringLike s2,int i2,int i3) { - int itot=i2+i3; - if(itot>s2.length()||i1+i3>s1.length()) return false; - if(!ign) { - for(int i=i2;is2.length()||i1+i3>s1.length()) return false; - if(!ign) { - for(int i=i2;i s2.length() || i1 + i3 > s1.length()) + { + return false; + } + if (!ign) + { + for (int i = i2; i < itot; i++) + { + if (s2.charAt(i) != s1.charAt(i1++)) + { + return false; } - return true; + } } - /** Duplicates the regionMatches routine of String -- but - makes use of the definitions of upper, lower, and title - case in this class when ignoreCase is set. */ - public static boolean regionMatches( String s1, - boolean ign,int i1,String s2,int i2,int i3) { - int itot=i2+i3; - if(itot>s2.length()||i1+i3>s1.length()) return false; - if(!ign) { - for(int i=i2;itrans2.java - * and trans2a.java. - */ -public class ChangeRule extends SpecialRule { - Regex NewRule; - public ChangeRule(ChangeRule c) { NewRule=c.NewRule; } - public ChangeRule(String nm,Regex rr) { name=nm; NewRule = rr; } - public ChangeRule(String nm,Transformer tr) { name=nm; NewRule = tr.rp; } - public Object clone1() { return new ChangeRule(this); } - public String toString1() { return "${="+name+"}"; } - public void apply(StringBufferLike sb,RegRes rr) {} + * of the form ${=name}. See trans2.java + * and trans2a.java. + */ +public class ChangeRule + extends SpecialRule +{ + Regex NewRule; + public ChangeRule(ChangeRule c) + { + NewRule = c.NewRule; + } + + public ChangeRule(String nm, Regex rr) + { + name = nm; + NewRule = rr; + } + + public ChangeRule(String nm, Transformer tr) + { + name = nm; + NewRule = tr.rp; + } + + public Object clone1() + { + return new ChangeRule(this); + } + + public String toString1() + { + return "${=" + name + "}"; + } + + public void apply(StringBufferLike sb, RegRes rr) + {} } diff --git a/src/com/stevesoft/pat/CodeRule.java b/src/com/stevesoft/pat/CodeRule.java index 31c779f..763bf3e 100755 --- a/src/com/stevesoft/pat/CodeRule.java +++ b/src/com/stevesoft/pat/CodeRule.java @@ -8,14 +8,25 @@ package com.stevesoft.pat; /** Implements the rules for \U, \L, \E, \Q in substitutions. */ -public final class CodeRule extends SpecialRule { - char c = 'E'; - public CodeRule() {} - public CodeRule(char c) { - this.c = c; - } - public void apply(StringBufferLike sb,RegRes res) { - sb.setMode(c); - } - public String toString1() { return "\\"+c; } +public final class CodeRule + extends SpecialRule +{ + char c = 'E'; + public CodeRule() + {} + + public CodeRule(char c) + { + this.c = c; + } + + public void apply(StringBufferLike sb, RegRes res) + { + sb.setMode(c); + } + + public String toString1() + { + return "\\" + c; + } } diff --git a/src/com/stevesoft/pat/Ctrl.java b/src/com/stevesoft/pat/Ctrl.java index ba7fc20..6fee70f 100755 --- a/src/com/stevesoft/pat/Ctrl.java +++ b/src/com/stevesoft/pat/Ctrl.java @@ -1,269 +1,271 @@ -package// +package // // This software is now distributed according to // the Lesser Gnu Public License. Please see // http://www.gnu.org/copyleft/lesser.txt for // the details. // -- Happy Computing! // -com.stevesoft.pat; + com.stevesoft.pat; -public class Ctrl { - public final static char[] cmap = { - (char)64, - (char)65, - (char)66, - (char)67, - (char)68, - (char)69, - (char)70, - (char)71, - (char)72, - (char)73, - (char)74, - (char)75, - (char)76, - (char)77, - (char)78, - (char)79, - (char)80, - (char)81, - (char)82, - (char)83, - (char)84, - (char)85, - (char)86, - (char)87, - (char)88, - (char)89, - (char)90, - (char)91, - (char)92, - (char)93, - (char)94, - (char)95, - (char)96, - (char)97, - (char)97, - (char)99, - (char)100, - (char)101, - (char)102, - (char)103, - (char)104, - (char)105, - (char)106, - (char)107, - (char)108, - (char)109, - (char)110, - (char)111, - (char)112, - (char)113, - (char)114, - (char)115, - (char)116, - (char)117, - (char)118, - (char)119, - (char)120, - (char)121, - (char)122, - (char)123, - (char)124, - (char)125, - (char)126, - (char)127, - (char)0, - (char)1, - (char)2, - (char)3, - (char)4, - (char)5, - (char)6, - (char)7, - (char)8, - (char)9, - (char)10, - (char)11, - (char)12, - (char)13, - (char)14, - (char)15, - (char)16, - (char)17, - (char)18, - (char)19, - (char)20, - (char)21, - (char)22, - (char)23, - (char)24, - (char)25, - (char)26, - (char)27, - (char)27, - (char)29, - (char)30, - (char)31, - (char)32, - (char)1, - (char)2, - (char)3, - (char)4, - (char)5, - (char)6, - (char)7, - (char)8, - (char)9, - (char)10, - (char)11, - (char)12, - (char)13, - (char)14, - (char)15, - (char)16, - (char)17, - (char)18, - (char)19, - (char)20, - (char)21, - (char)22, - (char)23, - (char)24, - (char)25, - (char)26, - (char)59, - (char)60, - (char)61, - (char)62, - (char)63, - (char)192, - (char)193, - (char)194, - (char)195, - (char)196, - (char)197, - (char)198, - (char)199, - (char)200, - (char)201, - (char)202, - (char)203, - (char)204, - (char)205, - (char)206, - (char)207, - (char)208, - (char)209, - (char)210, - (char)211, - (char)212, - (char)213, - (char)214, - (char)215, - (char)216, - (char)217, - (char)218, - (char)219, - (char)220, - (char)221, - (char)222, - (char)223, - (char)224, - (char)225, - (char)226, - (char)227, - (char)228, - (char)229, - (char)230, - (char)231, - (char)232, - (char)233, - (char)234, - (char)235, - (char)236, - (char)237, - (char)238, - (char)239, - (char)240, - (char)241, - (char)242, - (char)243, - (char)244, - (char)245, - (char)246, - (char)247, - (char)248, - (char)249, - (char)250, - (char)251, - (char)252, - (char)253, - (char)254, - (char)255, - (char)128, - (char)129, - (char)130, - (char)131, - (char)132, - (char)133, - (char)134, - (char)135, - (char)136, - (char)137, - (char)138, - (char)139, - (char)140, - (char)141, - (char)142, - (char)143, - (char)144, - (char)145, - (char)146, - (char)147, - (char)148, - (char)149, - (char)150, - (char)151, - (char)152, - (char)153, - (char)154, - (char)155, - (char)156, - (char)157, - (char)158, - (char)159, - (char)160, - (char)161, - (char)162, - (char)163, - (char)164, - (char)165, - (char)166, - (char)167, - (char)168, - (char)169, - (char)170, - (char)171, - (char)172, - (char)173, - (char)174, - (char)175, - (char)176, - (char)177, - (char)178, - (char)179, - (char)180, - (char)181, - (char)182, - (char)183, - (char)184, - (char)185, - (char)186, - (char)187, - (char)188, - (char)189, - (char)190, - (char)191 +public class Ctrl +{ + public final static char[] cmap = + { + (char) 64, + (char) 65, + (char) 66, + (char) 67, + (char) 68, + (char) 69, + (char) 70, + (char) 71, + (char) 72, + (char) 73, + (char) 74, + (char) 75, + (char) 76, + (char) 77, + (char) 78, + (char) 79, + (char) 80, + (char) 81, + (char) 82, + (char) 83, + (char) 84, + (char) 85, + (char) 86, + (char) 87, + (char) 88, + (char) 89, + (char) 90, + (char) 91, + (char) 92, + (char) 93, + (char) 94, + (char) 95, + (char) 96, + (char) 97, + (char) 97, + (char) 99, + (char) 100, + (char) 101, + (char) 102, + (char) 103, + (char) 104, + (char) 105, + (char) 106, + (char) 107, + (char) 108, + (char) 109, + (char) 110, + (char) 111, + (char) 112, + (char) 113, + (char) 114, + (char) 115, + (char) 116, + (char) 117, + (char) 118, + (char) 119, + (char) 120, + (char) 121, + (char) 122, + (char) 123, + (char) 124, + (char) 125, + (char) 126, + (char) 127, + (char) 0, + (char) 1, + (char) 2, + (char) 3, + (char) 4, + (char) 5, + (char) 6, + (char) 7, + (char) 8, + (char) 9, + (char) 10, + (char) 11, + (char) 12, + (char) 13, + (char) 14, + (char) 15, + (char) 16, + (char) 17, + (char) 18, + (char) 19, + (char) 20, + (char) 21, + (char) 22, + (char) 23, + (char) 24, + (char) 25, + (char) 26, + (char) 27, + (char) 27, + (char) 29, + (char) 30, + (char) 31, + (char) 32, + (char) 1, + (char) 2, + (char) 3, + (char) 4, + (char) 5, + (char) 6, + (char) 7, + (char) 8, + (char) 9, + (char) 10, + (char) 11, + (char) 12, + (char) 13, + (char) 14, + (char) 15, + (char) 16, + (char) 17, + (char) 18, + (char) 19, + (char) 20, + (char) 21, + (char) 22, + (char) 23, + (char) 24, + (char) 25, + (char) 26, + (char) 59, + (char) 60, + (char) 61, + (char) 62, + (char) 63, + (char) 192, + (char) 193, + (char) 194, + (char) 195, + (char) 196, + (char) 197, + (char) 198, + (char) 199, + (char) 200, + (char) 201, + (char) 202, + (char) 203, + (char) 204, + (char) 205, + (char) 206, + (char) 207, + (char) 208, + (char) 209, + (char) 210, + (char) 211, + (char) 212, + (char) 213, + (char) 214, + (char) 215, + (char) 216, + (char) 217, + (char) 218, + (char) 219, + (char) 220, + (char) 221, + (char) 222, + (char) 223, + (char) 224, + (char) 225, + (char) 226, + (char) 227, + (char) 228, + (char) 229, + (char) 230, + (char) 231, + (char) 232, + (char) 233, + (char) 234, + (char) 235, + (char) 236, + (char) 237, + (char) 238, + (char) 239, + (char) 240, + (char) 241, + (char) 242, + (char) 243, + (char) 244, + (char) 245, + (char) 246, + (char) 247, + (char) 248, + (char) 249, + (char) 250, + (char) 251, + (char) 252, + (char) 253, + (char) 254, + (char) 255, + (char) 128, + (char) 129, + (char) 130, + (char) 131, + (char) 132, + (char) 133, + (char) 134, + (char) 135, + (char) 136, + (char) 137, + (char) 138, + (char) 139, + (char) 140, + (char) 141, + (char) 142, + (char) 143, + (char) 144, + (char) 145, + (char) 146, + (char) 147, + (char) 148, + (char) 149, + (char) 150, + (char) 151, + (char) 152, + (char) 153, + (char) 154, + (char) 155, + (char) 156, + (char) 157, + (char) 158, + (char) 159, + (char) 160, + (char) 161, + (char) 162, + (char) 163, + (char) 164, + (char) 165, + (char) 166, + (char) 167, + (char) 168, + (char) 169, + (char) 170, + (char) 171, + (char) 172, + (char) 173, + (char) 174, + (char) 175, + (char) 176, + (char) 177, + (char) 178, + (char) 179, + (char) 180, + (char) 181, + (char) 182, + (char) 183, + (char) 184, + (char) 185, + (char) 186, + (char) 187, + (char) 188, + (char) 189, + (char) 190, + (char) 191 }; } diff --git a/src/com/stevesoft/pat/Custom.java b/src/com/stevesoft/pat/Custom.java index e7621a1..72aebc7 100755 --- a/src/com/stevesoft/pat/Custom.java +++ b/src/com/stevesoft/pat/Custom.java @@ -6,7 +6,8 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** Simple custom patterns. See deriv2.java @@ -14,29 +15,46 @@ import java.util.Hashtable; in the test directory. @see com.stevesoft.pat.CustomEndpoint */ -class Custom extends PatternSub { - String select; - Validator v; - int start; - Custom(String s) { - select = s; - v = (Validator)Regex.validators.get(s); - } - public int matchInternal(int pos,Pthings pt) { - start = pos; - return sub.matchInternal(pos,pt); - } - public String toString() { - String a = v.argsave == null ? "" : ":"+v.argsave; - return "(??"+select+a+")"+nextString(); - } - public patInt minChars() { return v.minChars(); } - public patInt maxChars() { return v.maxChars(); } - Pattern clone1(Hashtable h) { - Custom c = new Custom(select); - h.put(c,c); - h.put(this,c); - c.sub = sub.clone(h); - return c; - } +class Custom + extends PatternSub +{ + String select; + Validator v; + int start; + Custom(String s) + { + select = s; + v = (Validator) Regex.validators.get(s); + } + + public int matchInternal(int pos, Pthings pt) + { + start = pos; + return sub.matchInternal(pos, pt); + } + + public String toString() + { + String a = v.argsave == null ? "" : ":" + v.argsave; + return "(??" + select + a + ")" + nextString(); + } + + public patInt minChars() + { + return v.minChars(); + } + + public patInt maxChars() + { + return v.maxChars(); + } + + Pattern clone1(Hashtable h) + { + Custom c = new Custom(select); + h.put(c, c); + h.put(this, c); + c.sub = sub.clone(h); + return c; + } } diff --git a/src/com/stevesoft/pat/CustomEndpoint.java b/src/com/stevesoft/pat/CustomEndpoint.java index b8fc704..ac6c4ba 100755 --- a/src/com/stevesoft/pat/CustomEndpoint.java +++ b/src/com/stevesoft/pat/CustomEndpoint.java @@ -6,22 +6,38 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** This class is needed internally to make backtracking work - * correctly in user-defined patterns. - */ -class CustomEndpoint extends Pattern { - Custom c; - CustomEndpoint(Custom cm) { c = cm; } - public int matchInternal(int pos,Pthings pt) { - int npos = c.v.validate(pt.src,c.start,pos); - if(npos >= 0) - return nextMatch(npos,pt); - return -1; - } - public String toString() { return ""; } - Pattern clone1(Hashtable h) { - return new CustomEndpoint((Custom)c.clone(h)); + * correctly in user-defined patterns. + */ +class CustomEndpoint + extends Pattern +{ + Custom c; + CustomEndpoint(Custom cm) + { + c = cm; + } + + public int matchInternal(int pos, Pthings pt) + { + int npos = c.v.validate(pt.src, c.start, pos); + if (npos >= 0) + { + return nextMatch(npos, pt); } + return -1; + } + + public String toString() + { + return ""; + } + + Pattern clone1(Hashtable h) + { + return new CustomEndpoint( (Custom) c.clone(h)); + } } diff --git a/src/com/stevesoft/pat/DirFileRegex.java b/src/com/stevesoft/pat/DirFileRegex.java index c46762e..24c0cf6 100755 --- a/src/com/stevesoft/pat/DirFileRegex.java +++ b/src/com/stevesoft/pat/DirFileRegex.java @@ -9,10 +9,22 @@ package com.stevesoft.pat; /** This class is just like FileRegex, except that its accept method only returns true if the file matching the pattern is a directory.*/ -public class DirFileRegex extends FileRegex { - public DirFileRegex() { dirflag = DIR; } - public DirFileRegex(String fp) { super(fp); dirflag = DIR; } - public static String[] list(String f) { - return list(f,DIR); - } +public class DirFileRegex + extends FileRegex +{ + public DirFileRegex() + { + dirflag = DIR; + } + + public DirFileRegex(String fp) + { + super(fp); + dirflag = DIR; + } + + public static String[] list(String f) + { + return list(f, DIR); + } } diff --git a/src/com/stevesoft/pat/DotMulti.java b/src/com/stevesoft/pat/DotMulti.java index 514c161..4691728 100755 --- a/src/com/stevesoft/pat/DotMulti.java +++ b/src/com/stevesoft/pat/DotMulti.java @@ -6,120 +6,200 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** A special optimization of multi that is used when the - * common subpattern ".*" is encountered. - */ -class DotMulti extends PatternSub { - patInt fewestMatches,mostMatches; - public patInt minChars() { - return fewestMatches; - } - public patInt maxChars() { - return mostMatches; - } - public boolean matchFewest = false; + * common subpattern ".*" is encountered. + */ +class DotMulti + extends PatternSub +{ + patInt fewestMatches, mostMatches; + public patInt minChars() + { + return fewestMatches; + } - StringLike src=null; - int srclength=0; - boolean dotDoesntMatchCR=true; - DotMulti(patInt a,patInt b) { - fewestMatches = a; - mostMatches = b; - } - public String toString() { - return ".{" - +fewestMatches+","+mostMatches+"}"+ - (matchFewest ? "?" : "")+"(?# <= dot multi)"+ - nextString(); + public patInt maxChars() + { + return mostMatches; + } + + public boolean matchFewest = false; + + StringLike src = null; + int srclength = 0; + boolean dotDoesntMatchCR = true; + DotMulti(patInt a, patInt b) + { + fewestMatches = a; + mostMatches = b; + } + + public String toString() + { + return ".{" + + fewestMatches + "," + mostMatches + "}" + + (matchFewest ? "?" : "") + "(?# <= dot multi)" + + nextString(); + } + + final int submatchInternal(int pos, Pthings pt) + { + if (pos < srclength) + { + if (dotDoesntMatchCR) + { + if (src.charAt(pos) != '\n') + { + return 1 + pos; + } + } + else + { + return 1 + pos; + } } - final int submatchInternal(int pos,Pthings pt) { - if(pos < srclength) { - if(dotDoesntMatchCR) { - if(src.charAt(pos) != '\n') - return 1+pos; - } else return 1+pos; + return -1; + } + + final static int step = 1; + static int idcount = 1; + public int matchInternal(int pos, Pthings pt) + { + int m = -1; + int i = pos; + src = pt.src; + srclength = src.length(); + dotDoesntMatchCR = pt.dotDoesntMatchCR; + if (matchFewest) + { + int nMatches = 0; + while (fewestMatches.intValue() > nMatches) + { + i = submatchInternal(i, pt); + if (i < 0) + { + return -1; } + nMatches++; + } + if (i < 0) + { return -1; - } - final static int step = 1; - static int idcount = 1; - public int matchInternal(int pos,Pthings pt) { - int m=-1; - int i=pos; - src = pt.src; - srclength = src.length(); - dotDoesntMatchCR = pt.dotDoesntMatchCR; - if(matchFewest) { - int nMatches = 0; - while(fewestMatches.intValue() > nMatches) { - i=submatchInternal(i,pt); - if(i<0) return -1; - nMatches++; - } - if(i<0) return -1; - int ii = nextMatch(i,pt); - if(ii >= 0) return ii; - if(!mostMatches.finite()) { - while(i >= 0) { - i = submatchInternal(i,pt); - if(i < 0) return -1; - ii = nextMatch(i,pt); - if(ii >= 0) return ii; - } - } else { - while(i > 0) { - i = submatchInternal(i,pt); - if(i < 0) return -1; - nMatches++; - if(nMatches > mostMatches.intValue()) - return -1; - ii = nextMatch(i,pt); - if(ii >= 0) return ii; - } - } + } + int ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } + if (!mostMatches.finite()) + { + while (i >= 0) + { + i = submatchInternal(i, pt); + if (i < 0) + { return -1; + } + ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } } - int nMatches = 0; - while(fewestMatches.intValue() > nMatches) { - i=submatchInternal(i,pt); - if(i >= 0) - nMatches++; - else - return -1; + } + else + { + while (i > 0) + { + i = submatchInternal(i, pt); + if (i < 0) + { + return -1; + } + nMatches++; + if (nMatches > mostMatches.intValue()) + { + return -1; + } + ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } } - m=i; - if(mostMatches.finite()) { - while(nMatches < mostMatches.intValue()) { - i = submatchInternal(i,pt); - if(i>=0) { - m=i; - nMatches++; - } else break; - } - } else { - while(true) { - i = submatchInternal(i,pt); - if(i>=0) { - m=i; - nMatches++; - } else break; - } + } + return -1; + } + int nMatches = 0; + while (fewestMatches.intValue() > nMatches) + { + i = submatchInternal(i, pt); + if (i >= 0) + { + nMatches++; + } + else + { + return -1; + } + } + m = i; + if (mostMatches.finite()) + { + while (nMatches < mostMatches.intValue()) + { + i = submatchInternal(i, pt); + if (i >= 0) + { + m = i; + nMatches++; } - while(m >= pos) { - int r=nextMatch(m,pt); - if(r >= 0) return r; - m -= step; - nMatches--; - if(nMatches < fewestMatches.intValue()) - return -1; + else + { + break; } - return -1; + } } - Pattern clone1(Hashtable h) { - DotMulti dm = new DotMulti(fewestMatches,mostMatches); - dm.matchFewest = matchFewest; - return dm; + else + { + while (true) + { + i = submatchInternal(i, pt); + if (i >= 0) + { + m = i; + nMatches++; + } + else + { + break; + } + } } + while (m >= pos) + { + int r = nextMatch(m, pt); + if (r >= 0) + { + return r; + } + m -= step; + nMatches--; + if (nMatches < fewestMatches.intValue()) + { + return -1; + } + } + return -1; + } + + Pattern clone1(Hashtable h) + { + DotMulti dm = new DotMulti(fewestMatches, mostMatches); + dm.matchFewest = matchFewest; + return dm; + } } diff --git a/src/com/stevesoft/pat/End.java b/src/com/stevesoft/pat/End.java index 75e5acf..42894b3 100755 --- a/src/com/stevesoft/pat/End.java +++ b/src/com/stevesoft/pat/End.java @@ -6,37 +6,65 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; //class AddToEnd extends RegSyntax {}; /** Compiles the '$' or the '\Z' Pattern. It is an error to have further Pattern elements after '\Z'. It is the end of the String. */ -class End extends Pattern { - boolean retIsEnd; - End(boolean b) { retIsEnd = b; } - public int matchInternal(int pos,Pthings pt) { - if(retIsEnd && pt.mFlag && pos < pt.src.length()) { - if(pt.src.charAt(pos)=='\n') { - return nextMatch(pos,pt); - } - } - if(pt.src.length() == pos) - return nextMatch(pos,pt); - else if(pos= getl(v.elementAt(i))) { - Pattern p2 = (Pattern)v.elementAt(i); - char lo = min(getl(p),getl(p2)); - char hi = max(geth(p),geth(p2)); - nv.setElementAt(p=mkelem(lo,hi),nv.size()-1); - } else { - p = (Pattern)v.elementAt(i); - nv.addElement(p); - } - } - - b.v = v = nv; - } catch(RegSyntax e) { - e.printStackTrace(); + */ +public class FastBracket + extends Bracket +{ + int min, max; + BitSet bs; + FastBracket(boolean n) + { + super(n); + } + + // This routine can optimize a bracket, possibly + // it will replace it with a FastBracket. + static Bracket process(Bracket b, boolean ignc) + { + Vector v = b.v; + b.pv = null; + try + { + + // Expand out the vector to make separate + // entries for other cases if ignoreCase is + // turned on. + Vector nv = v; + if (ignc) + { + nv = new Vector(); + for (int i = 0; i < v.size(); i++) + { + Pattern p = (Pattern) v.elementAt(i); + nv.addElement(p); + if (p instanceof oneChar) + { + oneChar oc = (oneChar) p; + nv.addElement(new oneChar(oc.altc)); + } + else if (p instanceof Range) + { + Range ra = (Range) p; + nv.addElement(new Range(ra.altlo, ra.althi)); + } } + } + v = nv; - // We don't want these things to be empty. - Vector negv = neg(v); - if(v.size()==1) return b; - if(negv.size()==1) { - b.v = negv; - b.neg = !b.neg; - return b; + // Bubble sort, make sure elements + // are in order. This will allow us + // to merge them. + for (int i = 0; i < v.size() - 1; i++) + { + for (int j = 0; j < v.size() - 1; j++) + { + char c1 = getl(v.elementAt(j)); + char c2 = getl(v.elementAt(j + 1)); + if (c2 < c1) + { + Object o = v.elementAt(j); + v.setElementAt(v.elementAt(j + 1), j); + v.setElementAt(o, j + 1); + } } + } - // Now consider if we can make a FastBracket. - // Uses a BitSet to do a lookup. - FastBracket fb = newbrack(v,b.neg); - if(fb == null) - fb = newbrack(negv,!b.neg); - if(fb != null) { - fb.parent = b.parent; - fb.next = b.next; - return fb; + nv = new Vector(); + // merge -- remove overlaps + Pattern p = (Pattern) v.elementAt(0); + nv.addElement(p); + for (int i = 1; i < v.size(); i++) + { + if (geth(p) + 1 >= getl(v.elementAt(i))) + { + Pattern p2 = (Pattern) v.elementAt(i); + char lo = min(getl(p), getl(p2)); + char hi = max(geth(p), geth(p2)); + nv.setElementAt(p = mkelem(lo, hi), nv.size() - 1); + } + else + { + p = (Pattern) v.elementAt(i); + nv.addElement(p); } + } - // return the normal Bracket. - return b; + b.v = v = nv; + } + catch (RegSyntax e) + { + e.printStackTrace(); } - // Build a FastBracket and set bits. If this can't - // be done, return null. - final static FastBracket newbrack(Vector v,boolean neg) { - FastBracket fb = new FastBracket(neg); - fb.v = v; - if(v.size()==0) return null; - fb.min = getl(v.elementAt(0)); - fb.max = geth(v.elementAt(v.size()-1)); - if(fb.max-fb.min <= 256) { - fb.bs = new BitSet(fb.max-fb.min+1); - for(int i=0;ib ? a : b; + fb.min = getl(v.elementAt(0)); + fb.max = geth(v.elementAt(v.size() - 1)); + if (fb.max - fb.min <= 256) + { + fb.bs = new BitSet(fb.max - fb.min + 1); + for (int i = 0; i < v.size(); i++) + { + Object o = v.elementAt(i); + int min0 = getl(o) - fb.min; + int max0 = geth(o) - fb.min; + for (int j = min0; j <= max0; j++) + { + fb.bs.set(j); + } + } + return fb; + } + return null; + } + + // Negate a sorted Vector. Applying this + // operation twice should yield the same Vector + // back. + final static Vector neg(Vector v) + { + try + { + Vector nv = new Vector(); + if (v.size() == 0) + { + nv.addElement(new Range( (char) 0, (char) 65535)); + return nv; + } + int p0 = getl(v.elementAt(0)); + if (p0 != 0) + { + nv.addElement(mkelem( (char) 0, (char) (p0 - 1))); + } + for (int i = 0; i < v.size() - 1; i++) + { + int hi = getl(v.elementAt(i + 1)) - 1; + int lo = geth(v.elementAt(i)) + 1; + nv.addElement(mkelem( (char) lo, (char) hi)); + } + int pN = geth(v.lastElement()); + if (pN != 65535) + { + nv.addElement(mkelem( (char) (pN + 1), (char) 65535)); + } + return nv; + } + catch (RegSyntax rs) + { + return null; } + } - // getl -- get lower value of Range object, - // or get value of oneChar object. - final static char getl(Object o) { - Pattern p = (Pattern)o; - if(p instanceof Range) - return ((Range)p).lo; - return ((oneChar)p).c; + // Make either a Range or oneChar Object, depending on which + // is appropriate. + final static Pattern mkelem(char lo, char hi) + throws RegSyntax + { + return lo == hi ? (Pattern) (new oneChar(lo)) : (Pattern) (new Range(lo, hi)); + } + + static final char min(char a, char b) + { + return a < b ? a : b; + } + + static final char max(char a, char b) + { + return a > b ? a : b; + } + + // getl -- get lower value of Range object, + // or get value of oneChar object. + final static char getl(Object o) + { + Pattern p = (Pattern) o; + if (p instanceof Range) + { + return ( (Range) p).lo; } - // geth -- get higher value of Range object, - // or get value of oneChar object. - final static char geth(Object o) { - Pattern p = (Pattern)o; - if(p instanceof Range) - return ((Range)p).hi; - return ((oneChar)p).c; + return ( (oneChar) p).c; + } + + // geth -- get higher value of Range object, + // or get value of oneChar object. + final static char geth(Object o) + { + Pattern p = (Pattern) o; + if (p instanceof Range) + { + return ( (Range) p).hi; } + return ( (oneChar) p).c; + } - // This is the easy part! - public int matchInternal(int pos,Pthings pt) { - if(pos >= pt.src.length() || Masked(pos,pt)) return -1; - char c = pt.src.charAt(pos); - return (neg ^ (c >= min && c <= max && bs.get(c-min)) ) ? - nextMatch(pos+1,pt) : -1; + // This is the easy part! + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length() || Masked(pos, pt)) + { + return -1; } + char c = pt.src.charAt(pos); + return (neg ^ (c >= min && c <= max && bs.get(c - min))) ? + nextMatch(pos + 1, pt) : -1; + } } diff --git a/src/com/stevesoft/pat/FastMulti.java b/src/com/stevesoft/pat/FastMulti.java index 2a38281..53130fa 100755 --- a/src/com/stevesoft/pat/FastMulti.java +++ b/src/com/stevesoft/pat/FastMulti.java @@ -6,106 +6,166 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** A special case of Multi, implemented when minChars().equals(maxChars()), - * and some other conditions spelled out in RegOpt.safe4fm "Safe for - * FastMulti." It avoids stack growth problems as well as being slightly - * faster. - */ -class FastMulti extends PatternSub { - patInt fewestMatches,mostMatches; - public patInt minChars() { - return sub.countMinChars().mul(fewestMatches); - } - public patInt maxChars() { - return sub.countMaxChars().mul(mostMatches); - } - public boolean matchFewest = false; + * and some other conditions spelled out in RegOpt.safe4fm "Safe for + * FastMulti." It avoids stack growth problems as well as being slightly + * faster. + */ +class FastMulti + extends PatternSub +{ + patInt fewestMatches, mostMatches; + public patInt minChars() + { + return sub.countMinChars().mul(fewestMatches); + } - FastMulti(patInt a,patInt b,Pattern p) throws RegSyntax { - if(p == null) RegSyntaxError.endItAll("Null length pattern "+ - "followed by *, +, or other Multi."); - fewestMatches = a; - mostMatches = b; - sub = p; - step = p.countMinChars().intValue(); - sub.setParent(null); - } - public String toString() { - return sub.toString()+"{" - +fewestMatches+","+mostMatches+"}"+ - (matchFewest ? "?" : "")+"(?# <= fast multi)"+ - nextString(); + public patInt maxChars() + { + return sub.countMaxChars().mul(mostMatches); + } + + public boolean matchFewest = false; + + FastMulti(patInt a, patInt b, Pattern p) + throws RegSyntax + { + if (p == null) + { + RegSyntaxError.endItAll("Null length pattern " + + "followed by *, +, or other Multi."); } - int step = -1; - public int matchInternal(int pos,Pthings pt) { - int m=-1; - int i=pos; - int endstr = pt.src.length()-step; - patInt matches = new patInt(0); - if(matchFewest) { - if(fewestMatches.lessEq(matches)) { - int ii = nextMatch(i,pt); - if(ii >= 0) return ii; - } - while(i >= 0 && i <= endstr) { - i=sub.matchInternal(i,pt); - if(i >= 0) { - matches.inc(); - if(fewestMatches.lessEq(matches)) { - int ii = nextMatch(i,pt); - if(ii >= 0) return ii; - } - if(matches.equals(mostMatches)) - return -1; - } + fewestMatches = a; + mostMatches = b; + sub = p; + step = p.countMinChars().intValue(); + sub.setParent(null); + } + + public String toString() + { + return sub.toString() + "{" + + fewestMatches + "," + mostMatches + "}" + + (matchFewest ? "?" : "") + "(?# <= fast multi)" + + nextString(); + } + + int step = -1; + public int matchInternal(int pos, Pthings pt) + { + int m = -1; + int i = pos; + int endstr = pt.src.length() - step; + patInt matches = new patInt(0); + if (matchFewest) + { + if (fewestMatches.lessEq(matches)) + { + int ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } + } + while (i >= 0 && i <= endstr) + { + i = sub.matchInternal(i, pt); + if (i >= 0) + { + matches.inc(); + if (fewestMatches.lessEq(matches)) + { + int ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; } + } + if (matches.equals(mostMatches)) + { return -1; + } } - int nMatches = 0; - while(fewestMatches.intValue() > nMatches) { - i=sub.matchInternal(i,pt); - if(i >= 0) - nMatches++; - else - return -1; + } + return -1; + } + int nMatches = 0; + while (fewestMatches.intValue() > nMatches) + { + i = sub.matchInternal(i, pt); + if (i >= 0) + { + nMatches++; + } + else + { + return -1; + } + } + m = i; + if (mostMatches.finite()) + { + while (nMatches < mostMatches.intValue()) + { + i = sub.matchInternal(i, pt); + if (i >= 0) + { + m = i; + nMatches++; } - m=i; - if(mostMatches.finite()) { - while(nMatches < mostMatches.intValue()) { - i = sub.matchInternal(i,pt); - if(i>=0) { - m=i; - nMatches++; - } else break; - } - } else { - while(true) { - i = sub.matchInternal(i,pt); - if(i>=0) { - m=i; - nMatches++; - } else break; - } + else + { + break; + } + } + } + else + { + while (true) + { + i = sub.matchInternal(i, pt); + if (i >= 0) + { + m = i; + nMatches++; } - while(m >= pos) { - int r=nextMatch(m,pt); - if(r >= 0) return r; - m -= step; - nMatches--; - if(nMatches < fewestMatches.intValue()) - return -1; + else + { + break; } + } + } + while (m >= pos) + { + int r = nextMatch(m, pt); + if (r >= 0) + { + return r; + } + m -= step; + nMatches--; + if (nMatches < fewestMatches.intValue()) + { return -1; + } } - public Pattern clone1(Hashtable h) { - try { - FastMulti fm = new FastMulti(fewestMatches,mostMatches,sub.clone(h)); - fm.matchFewest = matchFewest; - return fm; - } catch(RegSyntax rs) { - return null; - } + return -1; + } + + public Pattern clone1(Hashtable h) + { + try + { + FastMulti fm = new FastMulti(fewestMatches, mostMatches, sub.clone(h)); + fm.matchFewest = matchFewest; + return fm; + } + catch (RegSyntax rs) + { + return null; } + } } diff --git a/src/com/stevesoft/pat/FileRegex.java b/src/com/stevesoft/pat/FileRegex.java index f5ac448..37729eb 100755 --- a/src/com/stevesoft/pat/FileRegex.java +++ b/src/com/stevesoft/pat/FileRegex.java @@ -6,6 +6,7 @@ // -- Happy Computing! // package com.stevesoft.pat; + import java.io.*; import java.util.*; @@ -40,176 +41,253 @@ import java.util.*; */ -public class FileRegex extends Regex { - /** Build an unitialized FileRegex. */ - public FileRegex() { dirflag=EITHER; } - /** Build a FileRegex form String s. */ - public FileRegex(String s) { - super(s); - dirflag = EITHER; +public class FileRegex + extends Regex +{ + /** Build an unitialized FileRegex. */ + public FileRegex() + { + dirflag = EITHER; + } + + /** Build a FileRegex form String s. */ + public FileRegex(String s) + { + super(s); + dirflag = EITHER; + } + + /** Compile a new pattern. + Throws @exception com.stevesoft.pat.RegSyntax for + nonsensical patterns like "[9-0]+" just as Regex does. + @see com.stevesoft.pat#compile(java.lang.String) + */ + public void compile(String s) + throws RegSyntax + { + String npat = toFileRegex(s); + super.compile(npat); + if (File.separatorChar == '\\') // MS-DOS + { + ignoreCase = true; } - /** Compile a new pattern. - Throws @exception com.stevesoft.pat.RegSyntax for - nonsensical patterns like "[9-0]+" just as Regex does. - @see com.stevesoft.pat#compile(java.lang.String) - */ - public void compile(String s) throws RegSyntax { - String npat = toFileRegex(s); - super.compile(npat); - if(File.separatorChar == '\\') // MS-DOS - ignoreCase = true; + } + + /** This is the method required by FileNameFilter. + To get a listing of files in the current directory + ending in .java, do this: +
+      File dot = new File(".");
+      FileRegex java_files = new FileRegex("*.java");
+      String[] file_list = dot.list(java_files);
+      
+ */ + public boolean accept(File dir, String s) + { + if (dirflag != EITHER) + { + File f = new File(s); + if (f.isDirectory() && dirflag == NONDIR) + { + return false; + } + if (!f.isDirectory() && dirflag == DIR) + { + return false; + } } - /** This is the method required by FileNameFilter. - To get a listing of files in the current directory - ending in .java, do this: -
-        File dot = new File(".");
-        FileRegex java_files = new FileRegex("*.java");
-        String[] file_list = dot.list(java_files);
-        
- */ - public boolean accept(File dir,String s) { - if(dirflag != EITHER) { - File f = new File(s); - if(f.isDirectory() && dirflag == NONDIR) - return false; - if(!f.isDirectory() && dirflag == DIR) - return false; - } - return matchAt(s,0); + return matchAt(s, 0); + } + + int dirflag = 0; + final static int EITHER = 0, DIR = 1, NONDIR = 2; + + /** Provides an alternative to File.list -- this + separates its argument according to File.pathSeparator. + To each path, it splits off a directory -- all characters + up to and including the first instance of File.separator -- + and a file pattern -- the part that comes after the directory. + It then produces a list of all the pattern matches on all + the paths. Thus "*.java:../*.java" would produce a list of + all the java files in this directory and in the ".." directory + on a Unix machine. "*.java;..\\*.java" would do the same thing + on a Dos machine. */ + public static String[] list(String f) + { + return list(f, EITHER); + } + + static String[] list(String f, int df) + { + //return list_(f,new FileRegex()); + StringTokenizer st = new StringTokenizer(f, File.pathSeparator); + Vector v = new Vector(); + while (st.hasMoreTokens()) + { + String path = st.nextToken(); + list1(path, v, df, true); } - int dirflag = 0; - final static int EITHER=0,DIR=1,NONDIR=2; + String[] sa = new String[v.size()]; + v.copyInto(sa); + return sa; + } - /** Provides an alternative to File.list -- this - separates its argument according to File.pathSeparator. - To each path, it splits off a directory -- all characters - up to and including the first instance of File.separator -- - and a file pattern -- the part that comes after the directory. - It then produces a list of all the pattern matches on all - the paths. Thus "*.java:../*.java" would produce a list of - all the java files in this directory and in the ".." directory - on a Unix machine. "*.java;..\\*.java" would do the same thing - on a Dos machine. */ - public static String[] list(String f) { - return list(f,EITHER); + final static Regex root = new Regex(File.separatorChar == '/' ? + "/$" : "(?:.:|)\\\\$"); + static void list1(String path, Vector v, int df, boolean rec) + { + // if path looks like a/b/c/ or d:\ then add . + if (root.matchAt(path, 0)) + { + v.addElement(path + "."); + return; } - static String[] list(String f,int df) { - //return list_(f,new FileRegex()); - StringTokenizer st = new StringTokenizer(f,File.pathSeparator); - Vector v = new Vector(); - while(st.hasMoreTokens()) { - String path = st.nextToken(); - list1(path,v,df,true); - } - String[] sa = new String[v.size()]; - v.copyInto(sa); - return sa; + File f = new File(path); + if (f.getParent() != null && rec) + { + Vector v2 = new Vector(); + list1(f.getParent(), v2, DIR, true); + for (int i = 0; i < v2.size(); i++) + { + String path2 = ( (String) v2.elementAt(i)) + + File.separator + f.getName(); + list1(path2, v, df, false); + } } - final static Regex root=new Regex(File.separatorChar=='/' ? - "/$" : "(?:.:|)\\\\$"); - static void list1(String path,Vector v,int df,boolean rec) { - // if path looks like a/b/c/ or d:\ then add . - if(root.matchAt(path,0)) { - v.addElement(path+"."); - return; - } - File f = new File(path); - if(f.getParent() != null && rec) { - Vector v2 = new Vector(); - list1(f.getParent(),v2,DIR,true); - for(int i=0;i) syntax that matches a balanced parenthesis. Not in perl 5. */ -class Group extends Pattern { - char op,cl; - Group(char opi,char cli) { - op = opi; - cl = cli; - } - public int matchInternal(int pos,Pthings pt) { - int i,count=1; - if(pos < pt.src.length()) - if(!Masked(pos,pt) && pt.src.charAt(pos) != op) - return -1; - for(i=pos+1;i a > -1 for this - // to make sense. - if(!a.lessEq(b)) - //throw new BadMultiArgs(); - RegSyntaxError.endItAll("Bad Multi Args: "+a+">"+b); - patInt i = new patInt(-1); - if(a.lessEq(i)) - //throw new BadMultiArgs(); - RegSyntaxError.endItAll("Bad Multi Args: "+a+"< 0"); + ret += parent.nextString(); + return ret; + } + + Multi_stage2(patInt a, patInt b, Pattern p) + throws RegSyntax + { + if (p == null) + { + RegSyntaxError.endItAll( + "Multiple match of Null pattern requested."); } - public Pattern getNext() { - return nextRet; + sub = p; + nextRet = this; + sub.setParent(this); + matchMin = a; + matchMax = b; + count = new patInt(0); + // we must have b > a > -1 for this + // to make sense. + if (!a.lessEq(b)) + { + //throw new BadMultiArgs(); + RegSyntaxError.endItAll("Bad Multi Args: " + a + ">" + b); } - int pos_old = -1; - public int matchInternal(int pos,Pthings pt) { - sub.setParent(this); + patInt i = new patInt( -1); + if (a.lessEq(i)) + { + //throw new BadMultiArgs(); + RegSyntaxError.endItAll("Bad Multi Args: " + a + "< 0"); + } + } - int canUse = -1; + public Pattern getNext() + { + return nextRet; + } - // check for some forms of infinite recursion... - if(pos_old >= 0 && pos == pos_old) { - return -1; - } - pos_old = pos; + int pos_old = -1; + public int matchInternal(int pos, Pthings pt) + { + sub.setParent(this); - if(matchMin.lessEq(count)) - canUse = pos; - if(!count.lessEq(matchMax) || pos > pt.src.length()) - return -1; + int canUse = -1; - if((matchFewest||count.equals(matchMax)) && canUse >= 0) { - Pattern n = super.getNext(); - if(n == null) - return canUse; - int ret = testMatch(n,pos,pt); - if(ret >= 0) { - return ret; - } - else canUse = -1; - } + // check for some forms of infinite recursion... + if (pos_old >= 0 && pos == pos_old) + { + return -1; + } + pos_old = pos; - count.inc(); - try { - if(count.lessEq(matchMax)) { - int r = testMatch(sub,pos,pt); - if(r >= 0) - return r; - } - } finally { count.dec(); } + if (matchMin.lessEq(count)) + { + canUse = pos; + } + if (!count.lessEq(matchMax) || pos > pt.src.length()) + { + return -1; + } - if(!matchFewest && canUse >= 0) { - Pattern n = super.getNext(); - if(n == null) - return canUse; - int ret = testMatch(n,pos,pt); - return ret; - } else return canUse; + if ( (matchFewest || count.equals(matchMax)) && canUse >= 0) + { + Pattern n = super.getNext(); + if (n == null) + { + return canUse; + } + int ret = testMatch(n, pos, pt); + if (ret >= 0) + { + return ret; + } + else + { + canUse = -1; + } } - public Pattern clone1(Hashtable h) { - try { - Multi_stage2 m = new Multi_stage2(matchMin,matchMax,sub.clone(h)); - m.matchFewest = matchFewest; - return m; - } catch(RegSyntax rs) { - return null; + + count.inc(); + try + { + if (count.lessEq(matchMax)) + { + int r = testMatch(sub, pos, pt); + if (r >= 0) + { + return r; } + } + } + finally + { + count.dec(); + } + + if (!matchFewest && canUse >= 0) + { + Pattern n = super.getNext(); + if (n == null) + { + return canUse; + } + int ret = testMatch(n, pos, pt); + return ret; + } + else + { + return canUse; + } + } + + public Pattern clone1(Hashtable h) + { + try + { + Multi_stage2 m = new Multi_stage2(matchMin, matchMax, sub.clone(h)); + m.matchFewest = matchFewest; + return m; + } + catch (RegSyntax rs) + { + return null; } + } }; diff --git a/src/com/stevesoft/pat/NoPattern.java b/src/com/stevesoft/pat/NoPattern.java index 3bac329..c5eba3c 100755 --- a/src/com/stevesoft/pat/NoPattern.java +++ b/src/com/stevesoft/pat/NoPattern.java @@ -1,19 +1,33 @@ -package// +package // // This software is now distributed according to // the Lesser Gnu Public License. Please see // http://www.gnu.org/copyleft/lesser.txt for // the details. // -- Happy Computing! // -com.stevesoft.pat; + com.stevesoft.pat; + import java.util.*; /** The idea behind this class is simply to eliminate the need for - * testing to see if Regex.thePattern is null. Every instruction - * we can eliminate from _search will help. - */ -public class NoPattern extends Pattern { - public String toString() { return "(?e=#)[^#d#D]"; } - public int matchInternal(int i,Pthings p) { return -1; } - Pattern clone1(Hashtable h) { return new NoPattern(); } + * testing to see if Regex.thePattern is null. Every instruction + * we can eliminate from _search will help. + */ +public class NoPattern + extends Pattern +{ + public String toString() + { + return "(?e=#)[^#d#D]"; + } + + public int matchInternal(int i, Pthings p) + { + return -1; + } + + Pattern clone1(Hashtable h) + { + return new NoPattern(); + } } diff --git a/src/com/stevesoft/pat/NonDirFileRegex.java b/src/com/stevesoft/pat/NonDirFileRegex.java index 7ef24a3..cb7b69d 100755 --- a/src/com/stevesoft/pat/NonDirFileRegex.java +++ b/src/com/stevesoft/pat/NonDirFileRegex.java @@ -9,10 +9,22 @@ package com.stevesoft.pat; /** This class is just like FileRegex, except that its accept method only returns true if the file matching the pattern is not a directory.*/ -public class NonDirFileRegex extends FileRegex { - public NonDirFileRegex() { dirflag = NONDIR; } - public NonDirFileRegex(String fp) { super(fp); dirflag = NONDIR; } - public static String[] list(String f) { - return list(f,NONDIR); - } +public class NonDirFileRegex + extends FileRegex +{ + public NonDirFileRegex() + { + dirflag = NONDIR; + } + + public NonDirFileRegex(String fp) + { + super(fp); + dirflag = NONDIR; + } + + public static String[] list(String f) + { + return list(f, NONDIR); + } } diff --git a/src/com/stevesoft/pat/NotImplementedError.java b/src/com/stevesoft/pat/NotImplementedError.java index f8835f2..246ecad 100755 --- a/src/com/stevesoft/pat/NotImplementedError.java +++ b/src/com/stevesoft/pat/NotImplementedError.java @@ -1,14 +1,17 @@ -package// +package // // This software is now distributed according to // the Lesser Gnu Public License. Please see // http://www.gnu.org/copyleft/lesser.txt for // the details. // -- Happy Computing! // -com.stevesoft.pat; + com.stevesoft.pat; -public class NotImplementedError extends Error { - public NotImplementedError(String s) { +public class NotImplementedError + extends Error +{ + public NotImplementedError(String s) + { super(s); } } diff --git a/src/com/stevesoft/pat/NullPattern.java b/src/com/stevesoft/pat/NullPattern.java index 082b0f3..abdc5fa 100755 --- a/src/com/stevesoft/pat/NullPattern.java +++ b/src/com/stevesoft/pat/NullPattern.java @@ -6,16 +6,32 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** This pattern matches nothing -- it is found in patterns - * like (hello|world|) where a zero-length subelement occurs. - */ -class NullPattern extends Pattern { - public String toString() { return nextString(); } - public int matchInternal(int p,Pthings pt) { - return nextMatch(p,pt); - } - public patInt maxChars() { return new patInt(0); } - Pattern clone1(Hashtable h) { return new NullPattern(); } + * like (hello|world|) where a zero-length subelement occurs. + */ +class NullPattern + extends Pattern +{ + public String toString() + { + return nextString(); + } + + public int matchInternal(int p, Pthings pt) + { + return nextMatch(p, pt); + } + + public patInt maxChars() + { + return new patInt(0); + } + + Pattern clone1(Hashtable h) + { + return new NullPattern(); + } } diff --git a/src/com/stevesoft/pat/NullRule.java b/src/com/stevesoft/pat/NullRule.java index 454c81e..fe4e837 100755 --- a/src/com/stevesoft/pat/NullRule.java +++ b/src/com/stevesoft/pat/NullRule.java @@ -10,10 +10,19 @@ package com.stevesoft.pat; /** The apply(StringBufferLike sb,RegRes res) method of this derivation of ReplaceRule appends nothing to the contents of the StringBuffer sb. @see com.stevesoft.pat.ReplaceRule - */ -public class NullRule extends ReplaceRule { - public NullRule() {} - public void apply(StringBufferLike sb,RegRes res) { - } - public String toString1() { return ""; } + */ +public class NullRule + extends ReplaceRule +{ + public NullRule() + {} + + public void apply(StringBufferLike sb, RegRes res) + { + } + + public String toString1() + { + return ""; + } } diff --git a/src/com/stevesoft/pat/Or.java b/src/com/stevesoft/pat/Or.java index 9791c74..05981aa 100755 --- a/src/com/stevesoft/pat/Or.java +++ b/src/com/stevesoft/pat/Or.java @@ -12,70 +12,116 @@ import java.util.*; /** This class implements the (?: ... ) extended Pattern. It provides a base class from which we derive the [ ... ], ( ... ), (?! ... ), and (?= ... ) patterns. */ -class Or extends Pattern { - Vector v; - Pattern[] pv = null; - Or() { v = new Vector(); } - String leftForm() { return "(?:"; } - String rightForm() { return ")"; } - String sepForm() { return "|"; } - public Or addOr(Pattern p) { - pv = null; - v.addElement(p); - p.setParent(this); - return this; +class Or + extends Pattern +{ + Vector v; + Pattern[] pv = null; + Or() + { + v = new Vector(); + } + + String leftForm() + { + return "(?:"; + } + + String rightForm() + { + return ")"; + } + + String sepForm() + { + return "|"; + } + + public Or addOr(Pattern p) + { + pv = null; + v.addElement(p); + p.setParent(this); + return this; + } + + public String toString() + { + int i; + StringBuffer sb = new StringBuffer(); + sb.append(leftForm()); + if (v.size() > 0) + { + sb.append( ( (Pattern) v.elementAt(0)).toString()); + } + for (i = 1; i < v.size(); i++) + { + sb.append(sepForm()); + sb.append( ( (Pattern) v.elementAt(i)).toString()); } - public String toString() { - int i; - StringBuffer sb = new StringBuffer(); - sb.append(leftForm()); - if(v.size()>0) - sb.append( ((Pattern)v.elementAt(0)).toString() ); - for(i=1;i= 0) + { + return r; + } + } + return -1; + } + + public patInt minChars() + { + if (v.size() == 0) + { + return new patInt(0); } - public int matchInternal(int pos,Pthings pt) { - if(pv == null) { - pv = new Pattern[v.size()]; - v.copyInto(pv); - } - for(int i=0;i= 0) - return r; - } - return -1; + patInt m = ( (Pattern) v.elementAt(0)).countMinChars(); + for (int i = 1; i < v.size(); i++) + { + Pattern p = (Pattern) v.elementAt(i); + m.mineq(p.countMinChars()); } - public patInt minChars() { - if(v.size()==0) return new patInt(0); - patInt m = ((Pattern)v.elementAt(0)).countMinChars(); - for(int i=1;i pt.marks[id+pt.nMarks]) { - int swap = pt.marks[id]; - pt.marks[id] = pt.marks[id+pt.nMarks]+1; - pt.marks[id+pt.nMarks] = swap+1; - } - return ret; + else if (pt.marks[id] > pt.marks[id + pt.nMarks]) + { + int swap = pt.marks[id]; + pt.marks[id] = pt.marks[id + pt.nMarks] + 1; + pt.marks[id + pt.nMarks] = swap + 1; } - public Pattern clone1(Hashtable h) { - OrMark om = new OrMark(id); - h.put(om,om); - h.put(this,om); - for(int i=0;i - */ -class PartialBuffer implements StringLike { + */ +class PartialBuffer + implements StringLike +{ int off; public boolean allowOverRun = true; public boolean overRun = false; StringBuffer sb; - PartialBuffer(StringBuffer sb) { + PartialBuffer(StringBuffer sb) + { this.sb = sb; } - public char charAt(int n) { + + public char charAt(int n) + { n += off; - if(n == sb.length()) { + if (n == sb.length()) + { overRun = true; return 0; } return sb.charAt(n); } - public int length() { - return allowOverRun ? sb.length()+1 : sb.length(); + + public int length() + { + return allowOverRun ? sb.length() + 1 : sb.length(); } - public int indexOf(char c) { - for(int i=0;iCopyright 2001, Steven R. Brandt -*/ /** -Class Pattern is the base class on which all the other pattern -elements are built. */ - -public abstract class Pattern { - /** The ESC character, the user can provide his own value - for the escape character through regex.esc */ - public final static char ESC = '\\'; - final static String PROTECT_THESE = "[]{}(),$,-\"^."; - - /** The interal match function, it must be provided by any - class which wishes to extend Pattern. */ - public abstract int matchInternal(int i,Pthings p); - public abstract String toString(); - - // Class Pattern is a singly linked list - // chained together by member next. The member - // parent is used so that sub patterns can access - // the chain they are branching from. - Pattern next=null,parent=null; - - /** This gets the next element of a Pattern that - we wish to match. If we are at the end of a - subchain of patterns, it will return us to the - parent chain. */ - public Pattern getNext() { - return next != null ? next : + */ +/** + Class Pattern is the base class on which all the other pattern + elements are built. */ + +public abstract class Pattern +{ + /** The ESC character, the user can provide his own value + for the escape character through regex.esc */ + public final static char ESC = '\\'; + final static String PROTECT_THESE = "[]{}(),$,-\"^."; + + /** The interal match function, it must be provided by any + class which wishes to extend Pattern. */ + public abstract int matchInternal(int i, Pthings p); + + public abstract String toString(); + + // Class Pattern is a singly linked list + // chained together by member next. The member + // parent is used so that sub patterns can access + // the chain they are branching from. + Pattern next = null, parent = null; + + /** This gets the next element of a Pattern that + we wish to match. If we are at the end of a + subchain of patterns, it will return us to the + parent chain. */ + public Pattern getNext() + { + return next != null ? next : (parent == null ? null : parent.getNext()); + } + + /** Call this method if you have a pattern element that + takes a sub pattern (such as Or), and + after you have added a sub pattern to the current + pattern element. */ + public void setParent(Pattern p) + { + if (next != null) + { + next.setParent(p); } - /** Call this method if you have a pattern element that - takes a sub pattern (such as Or), and - after you have added a sub pattern to the current - pattern element. */ - public void setParent(Pattern p) { - if(next != null) next.setParent(p); - else parent = p; - } - /** This determines if the remainder of a Pattern - matches. Type "return nextMatch" from within - matchInternal if the current - Pattern matches. Otherwise, return a -1.*/ - public int nextMatch(int i,Pthings pt) { - Pattern p = getNext(); - /*if(p == null) return i; - return p.matchInternal(i,pt);*/ - return p==null ? i : p.matchInternal(i,pt); - } - /** This is a toString() for the remainder - of the Pattern elements after this one. - use this when overriding toString(). Called from - within toString(). */ - public String nextString() { - if(next == null) return ""; - return next.toString(); - } - - /** a method to detect whether char c is in String s */ - final static boolean inString(char c,String s) { - int i; - for(i=0;itrans3.html. - */ -public class PopRule extends SpecialRule { - public PopRule() {} - public String toString1() { return "${POP}"; } + * file trans3.html. + */ +public class PopRule + extends SpecialRule +{ + public PopRule() + {} + + public String toString1() + { + return "${POP}"; + } } diff --git a/src/com/stevesoft/pat/Prop.java b/src/com/stevesoft/pat/Prop.java index 9319db5..b6490a6 100755 --- a/src/com/stevesoft/pat/Prop.java +++ b/src/com/stevesoft/pat/Prop.java @@ -8,45 +8,66 @@ package com.stevesoft.pat; /** Get Unicode properties for a character. See -http://unicode.org. */ -public class Prop { - /** Is this a "Decimal Digit" according to Unicode? */ - public final static boolean isDecimalDigit(char c) { - if(Bits.decimal_digit == null) - Bits.decimal_digit_f(); - return Bits.decimal_digit.get(c); + http://unicode.org. */ +public class Prop +{ + /** Is this a "Decimal Digit" according to Unicode? */ + public final static boolean isDecimalDigit(char c) + { + if (Bits.decimal_digit == null) + { + Bits.decimal_digit_f(); } - /** Is this a "Alphabetic" according to Unicode? */ - public final static boolean isAlphabetic(char c) { - if(Bits.letter == null) - Bits.letter_f(); - return Bits.letter.get(c); + return Bits.decimal_digit.get(c); + } + + /** Is this a "Alphabetic" according to Unicode? */ + public final static boolean isAlphabetic(char c) + { + if (Bits.letter == null) + { + Bits.letter_f(); } - /** Is this a "Math" according to Unicode? */ - public final static boolean isMath(char c) { - if(Bits.math == null) - Bits.math_f(); - return Bits.math.get(c); + return Bits.letter.get(c); + } + + /** Is this a "Math" according to Unicode? */ + public final static boolean isMath(char c) + { + if (Bits.math == null) + { + Bits.math_f(); } + return Bits.math.get(c); + } - /** Is this a "Currency" according to Unicode? */ - public final static boolean isCurrency(char c) { - if(Bits.currency == null) - Bits.currency_f(); - return Bits.currency.get(c); + /** Is this a "Currency" according to Unicode? */ + public final static boolean isCurrency(char c) + { + if (Bits.currency == null) + { + Bits.currency_f(); } + return Bits.currency.get(c); + } - /** Is c a white space character according to Unicode? */ - public final static boolean isWhite(char c) { - if(Bits.white == null) - Bits.white_f(); - return Bits.white.get(c); + /** Is c a white space character according to Unicode? */ + public final static boolean isWhite(char c) + { + if (Bits.white == null) + { + Bits.white_f(); } + return Bits.white.get(c); + } - /** Is c a punctuation character according to Unicode? */ - public final static boolean isPunct(char c) { - if(Bits.punct == null) - Bits.punct_f(); - return Bits.punct.get(c); + /** Is c a punctuation character according to Unicode? */ + public final static boolean isPunct(char c) + { + if (Bits.punct == null) + { + Bits.punct_f(); } + return Bits.punct.get(c); + } } diff --git a/src/com/stevesoft/pat/Pthings.java b/src/com/stevesoft/pat/Pthings.java index 0a465ce..84e327b 100755 --- a/src/com/stevesoft/pat/Pthings.java +++ b/src/com/stevesoft/pat/Pthings.java @@ -6,28 +6,30 @@ // -- Happy Computing! // package com.stevesoft.pat; + import java.util.*; -/** -Things that need to be kept track of during a +/** + Things that need to be kept track of during a match. Passed along with Pattern.matchInternal. */ -public class Pthings { - /** The current text we are attempting to match. */ - public StringLike src; - /** Whether we should ignore the case of letters in - this match. */ - public boolean ignoreCase; - public boolean mFlag; - /** The mask to use when dontMatchInQuotes is set. */ - public BitSet cbits; - /** Used to keep track of backreferences. */ - //public Hashtable marks; - public int[] marks; - public int nMarks; - /** Used to set the behavior of "." By default, it - now fails to match the '\n' character. */ - public boolean dotDoesntMatchCR; - /** Determine if Skipped strings need to be checked. */ - public boolean no_check; - int lastPos; +public class Pthings +{ + /** The current text we are attempting to match. */ + public StringLike src; + /** Whether we should ignore the case of letters in + this match. */ + public boolean ignoreCase; + public boolean mFlag; + /** The mask to use when dontMatchInQuotes is set. */ + public BitSet cbits; + /** Used to keep track of backreferences. */ + //public Hashtable marks; + public int[] marks; + public int nMarks; + /** Used to set the behavior of "." By default, it + now fails to match the '\n' character. */ + public boolean dotDoesntMatchCR; + /** Determine if Skipped strings need to be checked. */ + public boolean no_check; + int lastPos; } diff --git a/src/com/stevesoft/pat/PushRule.java b/src/com/stevesoft/pat/PushRule.java index cdc33f9..3fbfe14 100755 --- a/src/com/stevesoft/pat/PushRule.java +++ b/src/com/stevesoft/pat/PushRule.java @@ -11,12 +11,37 @@ package com.stevesoft.pat; trans3.java for further examples of how this is used. You will probably not want to call it directly. */ -public class PushRule extends SpecialRule { - Regex NewRule; - public PushRule(PushRule p) { NewRule = p.NewRule; } - public PushRule(String nm,Regex rr) { name=nm; NewRule = rr; } - public PushRule(String nm,Transformer tr) { name = nm; NewRule = tr.rp; } - public Object clone1() { return new PushRule(this); } - public String String1() { return "${+"+name+"}"; } - public void apply(StringBufferLike sbl,RegRes rr) {} +public class PushRule + extends SpecialRule +{ + Regex NewRule; + public PushRule(PushRule p) + { + NewRule = p.NewRule; + } + + public PushRule(String nm, Regex rr) + { + name = nm; + NewRule = rr; + } + + public PushRule(String nm, Transformer tr) + { + name = nm; + NewRule = tr.rp; + } + + public Object clone1() + { + return new PushRule(this); + } + + public String String1() + { + return "${+" + name + "}"; + } + + public void apply(StringBufferLike sbl, RegRes rr) + {} } diff --git a/src/com/stevesoft/pat/RBuffer.java b/src/com/stevesoft/pat/RBuffer.java index b9dda64..44657af 100755 --- a/src/com/stevesoft/pat/RBuffer.java +++ b/src/com/stevesoft/pat/RBuffer.java @@ -7,28 +7,41 @@ // package com.stevesoft.pat; - /** This class is used internally by RegexReader to store blocks of data. */ -class RBuffer { +class RBuffer +{ boolean done = false; StringBuffer sb; - int pos,epos; + int pos, epos; RBuffer next; - RBuffer() {} - RBuffer(StringBuffer sb) { this.sb = sb; } - public String toString() { - return "sb="+sb.toString().replace('\n',' ')+ - " pos="+pos+" epos="+epos+ - " sb.length()="+sb.length()+ - "\n"+sp(pos+3)+"^"+sp(epos-pos-1)+"^"; + RBuffer() + {} + + RBuffer(StringBuffer sb) + { + this.sb = sb; } - String sp(int n) { - if(n<=0) + + public String toString() + { + return "sb=" + sb.toString().replace('\n', ' ') + + " pos=" + pos + " epos=" + epos + + " sb.length()=" + sb.length() + + "\n" + sp(pos + 3) + "^" + sp(epos - pos - 1) + "^"; + } + + String sp(int n) + { + if (n <= 0) + { return ""; + } StringBuffer sb = new StringBuffer(n); - for(int i=0;i= hi) + { + //throw new BadRangeArgs(); + RegSyntaxError.endItAll("Badly formed []'s : " + lo + " >= " + hi); + } + o = new oneChar(lo); + altlo = o.altc; + o = new oneChar(hi); + althi = o.altc; + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length()) + { + return -1; } - Range(char loi,char hii) throws RegSyntax { - lo = loi; hi = hii; - oneChar o = null; - if(lo >= hi) - //throw new BadRangeArgs(); - RegSyntaxError.endItAll("Badly formed []'s : "+lo+" >= "+hi); - o = new oneChar(lo); - altlo = o.altc; - o = new oneChar(hi); - althi = o.altc; + if (Masked(pos, pt)) + { + return -1; } - public int matchInternal(int pos,Pthings pt) { - if(pos >= pt.src.length()) return -1; - if(Masked(pos,pt)) return -1; - char c = pt.src.charAt(pos); - if(lo <= c && c <= hi || - (pt.ignoreCase && (altlo <= c && c <= althi))) - return nextMatch(pos+1,pt); - return -1; + char c = pt.src.charAt(pos); + if (lo <= c && c <= hi || + (pt.ignoreCase && (altlo <= c && c <= althi))) + { + return nextMatch(pos + 1, pt); + } + return -1; + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + public Pattern clone1(Hashtable h) + { + try + { + Range r = new Range(lo, hi); + r.printBrackets = printBrackets; + return r; } - public patInt minChars() { return new patInt(1); } - public patInt maxChars() { return new patInt(1); } - public Pattern clone1(Hashtable h) { - try { - Range r = new Range(lo,hi); - r.printBrackets = printBrackets; - return r; - } catch(RegSyntax rs) { - return null; - } + catch (RegSyntax rs) + { + return null; } + } }; diff --git a/src/com/stevesoft/pat/RegOpt.java b/src/com/stevesoft/pat/RegOpt.java index bf99e36..f70df39 100755 --- a/src/com/stevesoft/pat/RegOpt.java +++ b/src/com/stevesoft/pat/RegOpt.java @@ -6,330 +6,464 @@ // -- Happy Computing! // package com.stevesoft.pat; + import java.util.*; /** This class is just like oneChar, but doesn't worry about case. */ -class FastChar extends oneChar { - FastChar(char c) { super(c); } - public int matchInternal(int p,Pthings pt) { - return (p < pt.src.length() - && pt.src.charAt(p)==c) ? - nextMatch(p+1,pt) : -1; - } - Pattern clone1(Hashtable h) { - return new FastChar(c); - } +class FastChar + extends oneChar +{ + FastChar(char c) + { + super(c); + } + + public int matchInternal(int p, Pthings pt) + { + return (p < pt.src.length() + && pt.src.charAt(p) == c) ? + nextMatch(p + 1, pt) : -1; + } + + Pattern clone1(Hashtable h) + { + return new FastChar(c); + } } /** This class is a hashtable keyed by Character - * Objects. It is used to match things of the - * form (?:a..|b..|c..|..) match with greater efficiency -- - * by using a Hashtable that indexes into the group - * of patterns. - */ -class Branch extends Pattern { - Hashtable h = new Hashtable(); - // We need to keep track of the order - // of the keys -- if we don't then - // recompiling the output of toString - // may produce errors by re-ordering - // ()'s and changing the id number of - // the backreference associated with - // a subpattern. - Vector keys = new Vector(); - Branch() {} - Pattern clone1(Hashtable x) { - Branch b = new Branch(); - b.keys = (Vector)keys.clone(); - x.put(this,b); - x.put(b,b); + * Objects. It is used to match things of the + * form (?:a..|b..|c..|..) match with greater efficiency -- + * by using a Hashtable that indexes into the group + * of patterns. + */ +class Branch + extends Pattern +{ + Hashtable h = new Hashtable(); + // We need to keep track of the order + // of the keys -- if we don't then + // recompiling the output of toString + // may produce errors by re-ordering + // ()'s and changing the id number of + // the backreference associated with + // a subpattern. + Vector keys = new Vector(); + Branch() + {} - for(int i=0;i (b(?:oo|ug)) - // during this process. However, we - // want (b(?:oo|ell)|bug) - NullPattern np = new NullPattern(); - np.add(n); - h.put(c,np); - } else { - h.put(c,n); - } - // Make sure we remember the order things were - // added into the Branch object so that we can - // properly convert it to a String. - keys.addElement(c); - } else if(p instanceof Or) { - ((Or)p).addOr(n); - } else if(p instanceof oneChar && n instanceof oneChar - && ((oneChar)p).c != ((oneChar)n).c) { - Branch b = new Branch(); - b.addc((oneChar)p,igc,dontMinQ); - b.addc((oneChar)n,igc,dontMinQ); - h.put(c,b); - b.setParent(this); - } else if(p instanceof Branch && n instanceof oneChar) { - ((Branch)p).addc((oneChar)n,igc,dontMinQ); - n.setParent(p); - } else { - // Create an Or object to receive the variety - // of branches in the pattern if the current letter - // is matched. We do not attempt to make these - // sub-branches into a Branch object yet. - Or o = new Or(); - o.setParent(this); + return count; + } - // Remove NullPattern from p -- it's no longer needed. - if(p instanceof NullPattern - && p.parent == null && p.next != null) { - o.addOr(p.next); - } else { - o.addOr(p); - } - o.addOr(n); + // adds a oneChar object to this Branch + void addc(oneChar o, boolean ignoreCase, boolean dontMinQ) + { + Pattern n = o.next; + if (n == null) + { + n = new NullPattern(); + } + else + { + n = RegOpt.opt(n, ignoreCase, dontMinQ); + } + n.setParent(this); + set(new Character(o.c), n, ignoreCase, dontMinQ); + if (ignoreCase) + { + if (o.c != o.altc) + { + set(new Character(o.altc), n, ignoreCase, dontMinQ); + } + if (o.c != o.altc2 && o.altc != o.altc2) + { + set(new Character(o.altc2), n, ignoreCase, dontMinQ); + } + } + } - Pattern optpat = RegOpt.opt(o,igc,dontMinQ); - h.put(c,optpat); - optpat.setParent(this); - } + void set(Character c, Pattern n, boolean igc, boolean dontMinQ) + { + Pattern p = (Pattern) h.get(c); + next = null; + // This letter is not yet used in the Branch object. + // We need to add it. + if (p == null) + { + if (n instanceof Or) + { + // A NullPattern is prepended to an Or + // to prevent confusing this object. + // For example: (boo|bug) => (b(?:oo|ug)) + // during this process. However, we + // want (b(?:oo|ell)|bug) + NullPattern np = new NullPattern(); + np.add(n); + h.put(c, np); + } + else + { + h.put(c, n); + } + // Make sure we remember the order things were + // added into the Branch object so that we can + // properly convert it to a String. + keys.addElement(c); } - public String toString() { - StringBuffer sb = new StringBuffer(); - // should protect this... - sb.append("(?:(?#branch)");// Hashtable)"); - for(int i=0;i= pt.src.length()) return -1; - Pattern n = (Pattern)h.get(new Character(pt.src.charAt(pos))); - if(n == null) return -1; - if(pt.cbits != null && pt.cbits.get(pos)) return -1; - return n.matchInternal(pos+1,pt); + else if (p instanceof oneChar && n instanceof oneChar + && ( (oneChar) p).c != ( (oneChar) n).c) + { + Branch b = new Branch(); + b.addc( (oneChar) p, igc, dontMinQ); + b.addc( (oneChar) n, igc, dontMinQ); + h.put(c, b); + b.setParent(this); } + else if (p instanceof Branch && n instanceof oneChar) + { + ( (Branch) p).addc( (oneChar) n, igc, dontMinQ); + n.setParent(p); + } + else + { + // Create an Or object to receive the variety + // of branches in the pattern if the current letter + // is matched. We do not attempt to make these + // sub-branches into a Branch object yet. + Or o = new Or(); + o.setParent(this); + + // Remove NullPattern from p -- it's no longer needed. + if (p instanceof NullPattern + && p.parent == null && p.next != null) + { + o.addOr(p.next); + } + else + { + o.addOr(p); + } + o.addOr(n); + + Pattern optpat = RegOpt.opt(o, igc, dontMinQ); + h.put(c, optpat); + optpat.setParent(this); + } + } + + public String toString() + { + StringBuffer sb = new StringBuffer(); + // should protect this... + sb.append("(?:(?#branch)"); // Hashtable)"); + for (int i = 0; i < keys.size(); i++) + { + Character c = (Character) keys.elementAt(i); + sb.append(c); + sb.append(h.get(c)); + if (i + 1 < keys.size()) + { + sb.append("|"); + } + } + sb.append(")"); + sb.append(nextString()); + return sb.toString(); + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length()) + { + return -1; + } + Pattern n = (Pattern) h.get(new Character(pt.src.charAt(pos))); + if (n == null) + { + return -1; + } + if (pt.cbits != null && pt.cbits.get(pos)) + { + return -1; + } + return n.matchInternal(pos + 1, pt); + } } /** This is just a place to put the optimizing function. It is never instantiated as an Object. It just sorts through the RegOpt looking for things it can change and make faster. */ -public class RegOpt { - static Pattern opt(Pattern p,boolean ignoreCase, - boolean dontMinQ) { - if(p == null) return p; - if(p instanceof Bracket) { - Bracket b = (Bracket)p; - // FastBracket is the only special - // optimized class to have its own - // source file. - p = FastBracket.process(b,ignoreCase); - //if(!(p instanceof FastBracket) - //p = Switch.process(b,ignoreCase); - p.next = b.next; - p.parent = b.parent; - } else if(p instanceof oneChar && !ignoreCase - && !dontMinQ) { - oneChar o = (oneChar)p; - p = new FastChar(o.c); - p.next = o.next; - p.parent = o.parent; - } else if(p instanceof Or - && ((Or)p).leftForm().equals("(?:") - && ((Or)p).v.size()==1) { // Eliminate this Or Object. - Or o = (Or)p; - p = (Pattern)o.v.elementAt(0); - p.setParent(null); - p = RegOpt.opt(p,ignoreCase,dontMinQ); - p.add(o.next); - } else if(p instanceof Or) { - Or o = (Or)p; - o.pv = null; - Vector v = o.v; - o.v = new Vector(); - Branch b = new Branch(); - b.parent = o.parent; - for(int i=0;i=1 || - (i+1 0) { - Pattern p2 = (Pattern)b.reduce(ignoreCase,dontMinQ); - if(p2 != null) { - o.addOr(p2); - b = new Branch(); - b.parent = o.parent; - } - } - o.addOr(opt(pp,ignoreCase,dontMinQ)); - } - } - if(b.keys.size()>0) { - Pattern p2=(Pattern)b.reduce(ignoreCase,dontMinQ); - if(p2 != null) - o.addOr(p2); - } - if(o.v.size()==1 - && o.leftForm().equals("(?:")) { // Eliminate Or Object - p = (Pattern)o.v.elementAt(0); - p.setParent(null); - p = RegOpt.opt(p,ignoreCase,dontMinQ); - p.add(o.next); +public class RegOpt +{ + static Pattern opt(Pattern p, boolean ignoreCase, + boolean dontMinQ) + { + if (p == null) + { + return p; + } + if (p instanceof Bracket) + { + Bracket b = (Bracket) p; + // FastBracket is the only special + // optimized class to have its own + // source file. + p = FastBracket.process(b, ignoreCase); + //if(!(p instanceof FastBracket) + //p = Switch.process(b,ignoreCase); + p.next = b.next; + p.parent = b.parent; + } + else if (p instanceof oneChar && !ignoreCase + && !dontMinQ) + { + oneChar o = (oneChar) p; + p = new FastChar(o.c); + p.next = o.next; + p.parent = o.parent; + } + else if (p instanceof Or + && ( (Or) p).leftForm().equals("(?:") + && ( (Or) p).v.size() == 1) + { // Eliminate this Or Object. + Or o = (Or) p; + p = (Pattern) o.v.elementAt(0); + p.setParent(null); + p = RegOpt.opt(p, ignoreCase, dontMinQ); + p.add(o.next); + } + else if (p instanceof Or) + { + Or o = (Or) p; + o.pv = null; + Vector v = o.v; + o.v = new Vector(); + Branch b = new Branch(); + b.parent = o.parent; + for (int i = 0; i < v.size(); i++) + { + Pattern pp = (Pattern) v.elementAt(i); + // We want to have at least two oneChar's in + // the Or Object to consider making a Branch. + if (pp instanceof oneChar && (b.h.size() >= 1 || + (i + 1 < v.size() && + v.elementAt(i + 1) instanceof oneChar))) + { + b.addc( (oneChar) pp, ignoreCase, dontMinQ); + } + else + { + if (b.keys.size() > 0) + { + Pattern p2 = (Pattern) b.reduce(ignoreCase, dontMinQ); + if (p2 != null) + { + o.addOr(p2); + b = new Branch(); + b.parent = o.parent; } - } else if(p instanceof FastMulti) { - PatternSub ps = (PatternSub)p; - ps.sub = RegOpt.opt(ps.sub,ignoreCase,dontMinQ); - } else if(p instanceof Multi && safe4fm( ((PatternSub)p).sub )) { - Multi m = (Multi)p; - FastMulti fm = null; - try { - fm = new FastMulti(m.a,m.b, - opt(m.sub,ignoreCase,dontMinQ)); - } catch(RegSyntax rs) {} - fm.parent = m.parent; - fm.matchFewest = m.matchFewest; - fm.next = m.next; - p = fm; + } + o.addOr(opt(pp, ignoreCase, dontMinQ)); } - if(p.next != null) - p.next = opt(p.next,ignoreCase,dontMinQ); - return p; - } - final static boolean safe4fm(Pattern x) { - while(x != null) { - if(x instanceof Bracket) - ; - else if(x instanceof Range) - ; - else if(x instanceof oneChar) - ; - else if(x instanceof Any) - ; - else if(x instanceof Custom - && ((Custom)x).v instanceof UniValidator) - ; - else if(x instanceof Or) { - Or o = (Or)x; - if(!o.leftForm().equals("(?:")) - return false; - patInt lo = o.countMinChars(); - patInt hi = o.countMaxChars(); - if(!lo.equals(hi)) - return false; - for(int i=0;i 0) + { + Pattern p2 = (Pattern) b.reduce(ignoreCase, dontMinQ); + if (p2 != null) + { + o.addOr(p2); } - return true; + } + if (o.v.size() == 1 + && o.leftForm().equals("(?:")) + { // Eliminate Or Object + p = (Pattern) o.v.elementAt(0); + p.setParent(null); + p = RegOpt.opt(p, ignoreCase, dontMinQ); + p.add(o.next); + } + } + else if (p instanceof FastMulti) + { + PatternSub ps = (PatternSub) p; + ps.sub = RegOpt.opt(ps.sub, ignoreCase, dontMinQ); + } + else if (p instanceof Multi && safe4fm( ( (PatternSub) p).sub)) + { + Multi m = (Multi) p; + FastMulti fm = null; + try + { + fm = new FastMulti(m.a, m.b, + opt(m.sub, ignoreCase, dontMinQ)); + } + catch (RegSyntax rs) + {} + fm.parent = m.parent; + fm.matchFewest = m.matchFewest; + fm.next = m.next; + p = fm; } - /* - public static void setParents(Regex r) { - setParents(r.thePattern,null); + if (p.next != null) + { + p.next = opt(p.next, ignoreCase, dontMinQ); } - static void setParents(Pattern p,Pattern x) { - if(p instanceof PatternSub && !(p instanceof FastMulti) - && !(p instanceof DotMulti)) - RegOpt.setParents( ((PatternSub)p).sub, p); - else if(p instanceof Or && !(p instanceof Bracket)) { - Or o = (Or)p; - for(int i=0;iCopyright 2001, Steven R. Brandt -*/ /** -This class is used to store a result from Regex */ -public class RegRes implements Cloneable { - protected int[] marks = null; - protected boolean didMatch_ = false; - protected StringLike src=null; - - /** Obtain the text String that was matched against. */ - public String getString() { return src.toString(); } - /** Obtain the source StringLike object. */ - public StringLike getStringLike() { return src; } - protected int charsMatched_=0,matchFrom_=0,numSubs_=0; - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("match="+matchedFrom()+":"+charsMatched()); - if(!didMatch()) return sb.toString(); - for(int i=0;inumSubs_) return -1; - //Integer in=(Integer)marks.get("left"+i); - //return in == null ? -1 : in.intValue(); - return marks[i]; - } - /** Obtains the number of characters matched by backreference i, or - -1 if backreference i was not matched. */ - public int charsMatched(int i) { - if(marks==null||i>numSubs_||!didMatch_) return -1; - //Integer in = (Integer)marks.get("right"+i); - //int i2 = in==null ? -1 : in.intValue(); - int mf = matchedFrom(i); - return mf < 0 ? -1 : marks[i+numSubs_]-matchedFrom(i); + didMatch_ = r.didMatch_; + src = r.src; + charsMatched_ = r.charsMatched_; + matchFrom_ = r.matchFrom_; + numSubs_ = r.numSubs_; + } + + public Object clone() + { + return new RegRes(this); + } + + public boolean equals(RegRes r) + { + if (charsMatched_ != r.charsMatched_ + || matchFrom_ != r.matchFrom_ + || didMatch_ != r.didMatch_ + || numSubs_ != r.numSubs_ + || !src.unwrap().equals(r.src.unwrap())) + { + return false; } - /** This is either equal to matchedFrom(i)+charsMatched(i) if the match - was successful, or -1 if it was not. */ - public int matchedTo(int i) { - if(marks==null||i>numSubs_||!didMatch_) return -1; - return marks[i+numSubs_]; + if (marks == null && r.marks != null) + { + return false; } - /** Obtains a substring matching the nth set - of parenthesis from the pattern. See - numSubs(void), or null if the nth backrefence did - not match. */ - public String stringMatched(int i) { - int mf = matchedFrom(i), cm = charsMatched(i); - return !didMatch_ || mf<0 || cm<0 ? null : - src.substring(mf,mf+cm); + if (marks != null && r.marks == null) + { + return false; } - /** This returns the part of the string that preceeds the match, - or null if the match failed.*/ - public String left() { - int mf = matchedFrom(); - return !didMatch_ || (mf<0) ? null : src.substring(0,mf); + for (int i = 1; i <= numSubs_; i++) + { + if (matchedFrom(i) != r.matchedFrom(i)) + { + return false; + } + else if (charsMatched(i) != r.charsMatched(i)) + { + return false; + } } - /** This returns the part of the string that follows the ith - backreference, or null if the backreference did not match. */ - public String left(int i) { - int mf = matchedFrom(i); - return !didMatch_ || (mf<0) ? null : src.substring(0,mf); + return true; + } + + /** Obtains the match if successful, null otherwise.*/ + public String stringMatched() + { + int mf = matchedFrom(), cm = charsMatched(); + return!didMatch_ || mf < 0 || cm < 0 ? null : + src.substring(mf, mf + cm); + } + + /** Obtains the position backreference number i begins to match, or + -1 if backreference i was not matched. */ + public int matchedFrom(int i) + { + if (marks == null || i > numSubs_) + { + return -1; } - /** This returns the part of the string that follows the match, - or null if the backreference did not match.*/ - public String right() { - int mf = matchedFrom(), cm = charsMatched(); - return !didMatch_ || mf<0 || cm<0 ? null : src.substring(mf+ - cm,src.length()); + //Integer in=(Integer)marks.get("left"+i); + //return in == null ? -1 : in.intValue(); + return marks[i]; + } + + /** Obtains the number of characters matched by backreference i, or + -1 if backreference i was not matched. */ + public int charsMatched(int i) + { + if (marks == null || i > numSubs_ || !didMatch_) + { + return -1; } - /** This returns the string to the right of the ith backreference, - or null if the backreference did not match. */ - public String right(int i) { - int mf = matchedFrom(i), cm = charsMatched(i); - return !didMatch_ || mf<0 || cm<0 ? null : - src.substring(mf+cm,src.length()); + //Integer in = (Integer)marks.get("right"+i); + //int i2 = in==null ? -1 : in.intValue(); + int mf = matchedFrom(i); + return mf < 0 ? -1 : marks[i + numSubs_] - matchedFrom(i); + } + + /** This is either equal to matchedFrom(i)+charsMatched(i) if the match + was successful, or -1 if it was not. */ + public int matchedTo(int i) + { + if (marks == null || i > numSubs_ || !didMatch_) + { + return -1; } - /** After a successful match, this returns the location of - the first matching character, or -1 if the match failed.*/ - public int matchedFrom() { return !didMatch_ ? -1 : matchFrom_; } - /** After a successful match, this returns the number of - characters in the match, or -1 if the match failed. */ - public int charsMatched() { return !didMatch_||matchFrom_<0 ? -1 : charsMatched_; } - /** This is matchedFrom()+charsMatched() after a successful match, - or -1 otherwise. */ - public int matchedTo() { return !didMatch_ ? -1 : matchFrom_+charsMatched_;} - /** This returns the number of - backreferences (parenthesis) in the pattern, - i.e. the pattern "(ab)" has - one, the pattern "(a)(b)" has two, etc. */ - public int numSubs() { return numSubs_; } - /** Contains true if the last match was successful. */ - public boolean didMatch() { return didMatch_; } - - /** An older name for matchedFrom. */ - public int matchFrom() { return matchedFrom(); } - /** An older name for stringMatched(). */ - public String substring() { return stringMatched(); } - /** An older name for matchedFrom. */ - public int matchFrom(int i) { return matchedFrom(i); } - /** An older name for stringMatched. */ - public String substring(int i) { return stringMatched(i); } + return marks[i + numSubs_]; + } + + /** Obtains a substring matching the nth set + of parenthesis from the pattern. See + numSubs(void), or null if the nth backrefence did + not match. */ + public String stringMatched(int i) + { + int mf = matchedFrom(i), cm = charsMatched(i); + return!didMatch_ || mf < 0 || cm < 0 ? null : + src.substring(mf, mf + cm); + } + + /** This returns the part of the string that preceeds the match, + or null if the match failed.*/ + public String left() + { + int mf = matchedFrom(); + return!didMatch_ || (mf < 0) ? null : src.substring(0, mf); + } + + /** This returns the part of the string that follows the ith + backreference, or null if the backreference did not match. */ + public String left(int i) + { + int mf = matchedFrom(i); + return!didMatch_ || (mf < 0) ? null : src.substring(0, mf); + } + + /** This returns the part of the string that follows the match, + or null if the backreference did not match.*/ + public String right() + { + int mf = matchedFrom(), cm = charsMatched(); + return!didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf + + cm, src.length()); + } + + /** This returns the string to the right of the ith backreference, + or null if the backreference did not match. */ + public String right(int i) + { + int mf = matchedFrom(i), cm = charsMatched(i); + return!didMatch_ || mf < 0 || cm < 0 ? null : + src.substring(mf + cm, src.length()); + } + + /** After a successful match, this returns the location of + the first matching character, or -1 if the match failed.*/ + public int matchedFrom() + { + return!didMatch_ ? -1 : matchFrom_; + } + + /** After a successful match, this returns the number of + characters in the match, or -1 if the match failed. */ + public int charsMatched() + { + return!didMatch_ || matchFrom_ < 0 ? -1 : charsMatched_; + } + + /** This is matchedFrom()+charsMatched() after a successful match, + or -1 otherwise. */ + public int matchedTo() + { + return!didMatch_ ? -1 : matchFrom_ + charsMatched_; + } + + /** This returns the number of + backreferences (parenthesis) in the pattern, + i.e. the pattern "(ab)" has + one, the pattern "(a)(b)" has two, etc. */ + public int numSubs() + { + return numSubs_; + } + + /** Contains true if the last match was successful. */ + public boolean didMatch() + { + return didMatch_; + } + + /** An older name for matchedFrom. */ + public int matchFrom() + { + return matchedFrom(); + } + + /** An older name for stringMatched(). */ + public String substring() + { + return stringMatched(); + } + + /** An older name for matchedFrom. */ + public int matchFrom(int i) + { + return matchedFrom(i); + } + + /** An older name for stringMatched. */ + public String substring(int i) + { + return stringMatched(i); + } } diff --git a/src/com/stevesoft/pat/RegSyntax.java b/src/com/stevesoft/pat/RegSyntax.java index 1a51d9e..ac47c1a 100755 --- a/src/com/stevesoft/pat/RegSyntax.java +++ b/src/com/stevesoft/pat/RegSyntax.java @@ -10,15 +10,20 @@ package com.stevesoft.pat; /* Shareware: package pat Copyright 2001, Steven R. Brandt -*/ + */ /** -This type of syntax error is thrown whenever a syntax error + This type of syntax error is thrown whenever a syntax error is encountered in the pattern. It may not be caught directly, as it is not in the throws clause of any method. To detect it, catch Throwable, and use instanceof to see if it is a RegSyntax. */ -public class RegSyntax extends Exception { - RegSyntax() {} - RegSyntax(String msg) { - super(msg); - } +public class RegSyntax + extends Exception +{ + RegSyntax() + {} + + RegSyntax(String msg) + { + super(msg); + } }; diff --git a/src/com/stevesoft/pat/RegSyntaxError.java b/src/com/stevesoft/pat/RegSyntaxError.java index c403412..688c906 100755 --- a/src/com/stevesoft/pat/RegSyntaxError.java +++ b/src/com/stevesoft/pat/RegSyntaxError.java @@ -17,13 +17,26 @@ package com.stevesoft.pat; I strongly recommend turning this flag on, however, as I think it is more likely to help than to hurt your programming efforts. - */ -public class RegSyntaxError extends Error { - public static boolean RegSyntaxErrorEnabled = false; - public RegSyntaxError() {} - public RegSyntaxError(String s) { super(s); } - final static void endItAll(String s) throws RegSyntax { - if(RegSyntaxErrorEnabled) throw new RegSyntaxError(s); - throw new RegSyntax(s); + */ +public class RegSyntaxError + extends Error +{ + public static boolean RegSyntaxErrorEnabled = false; + public RegSyntaxError() + {} + + public RegSyntaxError(String s) + { + super(s); + } + + final static void endItAll(String s) + throws RegSyntax + { + if (RegSyntaxErrorEnabled) + { + throw new RegSyntaxError(s); } + throw new RegSyntax(s); + } } diff --git a/src/com/stevesoft/pat/Regex.java b/src/com/stevesoft/pat/Regex.java index 665632e..af5cbcc 100755 --- a/src/com/stevesoft/pat/Regex.java +++ b/src/com/stevesoft/pat/Regex.java @@ -6,1424 +6,2020 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.*; + import java.io.*; -import com.stevesoft.pat.wrap.StringWrap; +import java.util.*; +import com.stevesoft.pat.wrap.*; /** Matches a Unicode punctuation character. */ -class UnicodePunct extends UniValidator { - public int validate(StringLike s,int from,int to) { - return from= s.length()) return -1; - char c = s.charAt(from); - return (Prop.isAlphabetic(c)||Prop.isDecimalDigit(c)||c=='_') ? to : -1; - } +class UnicodeW + extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + if (from >= s.length()) + { + return -1; + } + char c = s.charAt(from); + return (Prop.isAlphabetic(c) || Prop.isDecimalDigit(c) || c == '_') ? to : + -1; + } } /** Matches a character that is not a Unicode alphanumeric or underscore. */ -class NUnicodeW extends UniValidator { - public int validate(StringLike s,int from,int to) { - if(from >= s.length()) return -1; - char c = s.charAt(from); - return !(Prop.isAlphabetic(c)||Prop.isDecimalDigit(c)||c=='_') ? to : -1; - } +class NUnicodeW + extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + if (from >= s.length()) + { + return -1; + } + char c = s.charAt(from); + return! (Prop.isAlphabetic(c) || Prop.isDecimalDigit(c) || c == '_') ? to : + -1; + } } /** Matches a Unicode decimal digit. */ -class UnicodeDigit extends UniValidator { - public int validate(StringLike s,int from,int to) { - return from -For the purpose of this documentation, the fact that java interprets the -backslash will be ignored. In practice, however, you will need a -double backslash to obtain a string that contains a single backslash -character. Thus, the example pattern "\b" should really be typed -as "\\b" inside java code. -

-Note that Regex is part of package "com.stevesoft.pat". -To use it, simply import -com.stevesoft.pat.Regex at the top of your file. -

-Regex is made with a constructor that takes a String that defines -the regular expression. Thus, for example -

+ Regex provides the parser which constructs the linked list of
+ Pattern classes from a String.
+ 

+ For the purpose of this documentation, the fact that java interprets the + backslash will be ignored. In practice, however, you will need a + double backslash to obtain a string that contains a single backslash + character. Thus, the example pattern "\b" should really be typed + as "\\b" inside java code. +

+ Note that Regex is part of package "com.stevesoft.pat". + To use it, simply import + com.stevesoft.pat.Regex at the top of your file. +

+ Regex is made with a constructor that takes a String that defines + the regular expression. Thus, for example +

       Regex r = new Regex("[a-c]*");
-
-matches any number of characters so long as the are 'a', 'b', or 'c'). -

-To attempt to match the Pattern to a given string, you can use either -the search(String) member function, or the matchAt(String,int position) -member function. These functions return a boolean which tells you -whether or not the thing worked, and sets the methods "charsMatched()" -and "matchedFrom()" in the Regex object appropriately. -

-The portion of the string before the match can be obtained by the -left() member, and the portion after the match can be obtained -by the right() member. -

-Essentially, this package implements a syntax that is very much -like the perl 5 regular expression syntax. - -Longer example: -

+ 
+ matches any number of characters so long as the are 'a', 'b', or 'c'). +

+ To attempt to match the Pattern to a given string, you can use either + the search(String) member function, or the matchAt(String,int position) + member function. These functions return a boolean which tells you + whether or not the thing worked, and sets the methods "charsMatched()" + and "matchedFrom()" in the Regex object appropriately. +

+ The portion of the string before the match can be obtained by the + left() member, and the portion after the match can be obtained + by the right() member. +

+ Essentially, this package implements a syntax that is very much + like the perl 5 regular expression syntax. + + Longer example: +

         Regex r = new Regex("x(a|b)y");
         r.matchAt("xay",0);
         System.out.println("sub = "+r.stringMatched(1));
-
-The above would print "sub = a". -
+ 
+ The above would print "sub = a". +
         r.left() // would return "x"
         r.right() // would return "y"
-
-

-Differences between this package and perl5:
-The extended Pattern for setting flags, is now supported, -but the flags are different. "(?i)" tells the pattern to -ignore case, "(?Q)" sets the "dontMatchInQuotes" flag, and -"(?iQ)" sets them both. You can change the escape character. -The pattern

(?e=#)#d+
is the same as
\d+
, -but note that the sequence
(?e=#)
must occur -at the very beginning of the pattern. There may be other small -differences as well. I will either make my package conform -or note them as I become aware of them. -

-This package supports additional patterns not in perl5: -

- - - -
(?@())GroupThis matches all characters between -the '(' character and the balancing ')' character. Thus, it will -match "()" as well as "(())". The balancing characters are -arbitrary, thus (?@{}) matches on "{}" and "{{}}".
(?<1)BackupMoves the pointer backwards within the text. -This allows you to make a "look behind." It fails if it -attempts to move to a position before the beginning of the string. -"x(?<1)" is equivalent to "(?=x)". The number, 1 in this example, -is the number of characters to move backwards.
-
- -@author Steven R. Brandt -@version package com.stevesoft.pat, release 1.5.3 -@see Pattern -*/ -public class Regex extends RegRes implements FilenameFilter { - /** BackRefOffset gives the identity number of the first - pattern. Version 1.0 used zero, version 1.1 uses 1 to be - more compatible with perl. */ - static int BackRefOffset = 1; - private static Pattern none = new NoPattern(); - Pattern thePattern = none; - patInt minMatch = new patInt(0); - - static Hashtable validators = new Hashtable(); - static { - define("p","(?>1)",new UnicodePunct()); - define("P","(?>1)",new NUnicodePunct()); - define("s","(?>1)",new UnicodeWhite()); - define("S","(?>1)",new NUnicodeWhite()); - define("w","(?>1)",new UnicodeW()); - define("W","(?>1)",new NUnicodeW()); - define("d","(?>1)",new UnicodeDigit()); - define("D","(?>1)",new NUnicodeDigit()); - define("m","(?>1)",new UnicodeMath()); - define("M","(?>1)",new NUnicodeMath()); - define("c","(?>1)",new UnicodeCurrency()); - define("C","(?>1)",new NUnicodeCurrency()); - define("a","(?>1)",new UnicodeAlpha()); - define("A","(?>1)",new NUnicodeAlpha()); - define("uc","(?>1)",new UnicodeUpper()); - define("lc","(?>1)",new UnicodeLower()); - } - - /** Set the dontMatch in quotes flag. */ - public void setDontMatchInQuotes(boolean b) { - dontMatchInQuotes = b; - } - /** Find out if the dontMatchInQuotes flag is enabled. */ - public boolean getDontMatchInQuotes() { - return dontMatchInQuotes; - } - boolean dontMatchInQuotes = false; - - /** Set the state of the ignoreCase flag. If set to true, then - the pattern matcher will ignore case when searching for a - match. */ - public void setIgnoreCase(boolean b) { - ignoreCase = b; - } - /** Get the state of the ignoreCase flag. Returns true if we - are ignoring the case of the pattern, false otherwise. */ - public boolean getIgnoreCase() { - return ignoreCase; - } - boolean ignoreCase = false; - - static boolean defaultMFlag = false; - /** Set the default value of the m flag. If it - is set to true, then the MFlag will be on - for any regex search executed. */ - public static void setDefaultMFlag(boolean mFlag) { - defaultMFlag = mFlag; - } - /** Get the default value of the m flag. If it - is set to true, then the MFlag will be on - for any regex search executed. */ - public static boolean getDefaultMFlag() { - return defaultMFlag; - } - - /** Initializes the object without a Pattern. To supply a Pattern - use compile(String s). - @see com.stevesoft.pat.Regex#compile(java.lang.String) - */ - public Regex() {} - /** Create and compile a Regex, but do not throw any exceptions. - If you wish to have exceptions thrown for syntax errors, - you must use the Regex(void) constructor to create the - Regex object, and then call the compile method. Therefore, you - should only call this method when you know your pattern is right. - I will probably become more like - @see com.stevesoft.pat.Regex#search(java.lang.String) - @see com.stevesoft.pat.Regex#compile(java.lang.String) - */ - public Regex(String s) { - try { - compile(s); - } catch(RegSyntax rs) {} - } - - ReplaceRule rep = null; - /** Create and compile both a Regex and a ReplaceRule. - @see com.stevesoft.pat.ReplaceRule - @see com.stevesoft.pat.Regex#compile(java.lang.String) - */ - public Regex(String s,String rp) { - this(s); - rep = ReplaceRule.perlCode(rp); - } - /** Create and compile a Regex, but give it the ReplaceRule - specified. This allows the user finer control of the - Replacement process, if that is desired. - @see com.stevesoft.pat.ReplaceRule - @see com.stevesoft.pat.Regex#compile(java.lang.String) - */ - public Regex(String s,ReplaceRule rp) { - this(s); - rep = rp; - } - - /** Change the ReplaceRule of this Regex by compiling - a new one using String rp. */ - public void setReplaceRule(String rp) { - rep = ReplaceRule.perlCode(rp); - repr = null; // Clear Replacer history - } - - /** Change the ReplaceRule of this Regex to rp. */ - public void setReplaceRule(ReplaceRule rp) { - rep = rp; - } - /** Test to see if a custom defined rule exists. - @see com.stevesoft.pat#define(java.lang.String,java.lang.String,Validator) - */ - public static boolean isDefined(String nm) { - return validators.get(nm) != null; - } - /** Removes a custom defined rule. - @see com.stevesoft.pat#define(java.lang.String,java.lang.String,Validator) - */ - public static void undefine(String nm) { - validators.remove(nm); - } - /** Defines a method to create a new rule. See test/deriv2.java - and test/deriv3.java for examples of how to use it. */ - public static void define(String nm,String pat,Validator v) { - v.pattern = pat; - validators.put(nm,v); - } - /** Defines a shorthand for a pattern. The pattern will be - invoked by a string that has the form "(??"+nm+")". - */ - public static void define(String nm,String pat) { - validators.put(nm,pat); - } - - /** Get the current ReplaceRule. */ - public ReplaceRule getReplaceRule() { return rep; } - - Replacer repr = null; - final Replacer _getReplacer() { - return repr==null ? repr=new Replacer() : repr; - } - public Replacer getReplacer() { - if(repr == null) - repr = new Replacer(); - repr.rh.me = this; - repr.rh.prev = null; - return repr; - } - /** Replace the first occurence of this pattern in String s - according to the ReplaceRule. - @see com.stevesoft.pat.ReplaceRule - @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceFirst(String s) { - return _getReplacer().replaceFirstRegion(s,this,0,s.length()).toString(); - } - /** Replace the first occurence of this pattern in String s - beginning with position pos according to the ReplaceRule. - @see com.stevesoft.pat.ReplaceRule - @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceFirstFrom(String s,int pos) { - return _getReplacer().replaceFirstRegion(s,this,pos,s.length()).toString(); - } - /** Replace the first occurence of this pattern in String s - beginning with position start and ending with end - according to the ReplaceRule. - @see com.stevesoft.pat.ReplaceRule - @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceFirstRegion(String s,int start,int end) { - return _getReplacer().replaceFirstRegion(s,this,start,end).toString(); - } - - /** Replace all occurences of this pattern in String s - according to the ReplaceRule. - @see com.stevesoft.pat.ReplaceRule - @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceAll(String s) { - return _getReplacer().replaceAllRegion(s,this,0,s.length()).toString(); - } - public StringLike replaceAll(StringLike s) { - return _getReplacer().replaceAllRegion(s,this,0,s.length()); - } - /** Replace all occurences of this pattern in String s - beginning with position pos according to the ReplaceRule. - @see com.stevesoft.pat.ReplaceRule - @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceAllFrom(String s,int pos) { - return _getReplacer().replaceAllRegion(s,this,pos,s.length()).toString(); - } - /** Replace all occurences of this pattern in String s - beginning with position start and ending with end - according to the ReplaceRule. - @see com.stevesoft.pat.ReplaceRule - @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceAllRegion(String s,int start,int end) { - return _getReplacer().replaceAllRegion(s,this,start,end).toString(); - } - - - /** Essentially clones the Regex object */ - public Regex(Regex r) { - super((RegRes)r); - dontMatchInQuotes = r.dontMatchInQuotes; - esc = r.esc; - ignoreCase = r.ignoreCase; - gFlag = r.gFlag; - if(r.rep==null) - rep = null; - else - rep = (ReplaceRule)r.rep.clone(); - /* try { - compile(r.toString()); - } catch(RegSyntax r_) {} */ - thePattern = r.thePattern.clone(new Hashtable()); - minMatch = r.minMatch; - skipper = r.skipper; - } - - /** By default, - the escape character is the backslash, but you can - make it anything you want by setting this variable. */ - public char esc = Pattern.ESC; - /** This method compiles a regular expression, making it - possible to call the search or matchAt methods. - @exception com.stevesoft.pat.RegSyntax - is thrown if a syntax error is encountered - in the pattern. - For example, "x{3,1}" or "*a" are not valid - patterns. - @see com.stevesoft.pat.Regex#search - @see com.stevesoft.pat.Regex#matchAt - */ - public void compile(String prepat) throws RegSyntax { - String postpat = parsePerl.codify(prepat,true); - String pat = postpat==null ? prepat : postpat; - minMatch = null; - ignoreCase = false; - dontMatchInQuotes = false; - Rthings mk = new Rthings(this); - int offset = mk.val; - String newpat = pat; - thePattern = none; - p = null; - or = null; - minMatch = new patInt(0); - StrPos sp = new StrPos(pat,0); - if(sp.incMatch("(?e=")) { - char newEsc = sp.c; - sp.inc(); - if(sp.match(')')) - newpat = reEscape(pat.substring(6), - newEsc,Pattern.ESC); - } else if(esc != Pattern.ESC) - newpat = reEscape(pat,esc,Pattern.ESC); - thePattern = _compile(newpat,mk); - numSubs_ = mk.val-offset; - mk.set(this); - } - - /* If a Regex is compared against a Regex, a check is - done to see that the patterns are equal as well as - the most recent match. If a Regex is compare with - a RegRes, only the result of the most recent match - is compared. */ - public boolean equals(Object o) { - if(o instanceof Regex) { - if(toString().equals(o.toString())) - return super.equals(o); - else - return false; - } else return super.equals(o); - } - - /** A clone by any other name would smell as sweet. */ - public Object clone() { - return new Regex(this); - } - /** Return a clone of the underlying RegRes object. */ - public RegRes result() { - return (RegRes)super.clone(); - } - - // prep sets global variables of class - // Pattern so that it can access them - // during an attempt at a match - Pthings pt = new Pthings(); - final Pthings prep(StringLike s) { - //if(gFlag) - pt.lastPos = matchedTo(); - if(pt.lastPos < 0) pt.lastPos = 0; - if( (s==null ? null : s.unwrap()) != (src==null ? null : s.unwrap()) ) - pt.lastPos = 0; - src = s; - pt.dotDoesntMatchCR=dotDoesntMatchCR && (!sFlag); - pt.mFlag = (mFlag | defaultMFlag); - pt.ignoreCase = ignoreCase; - pt.no_check = false; - if(pt.marks != null) - for(int i=0;istart
*/ - public boolean searchFrom(String s,int start) { - if(s==null) - throw new NullPointerException("Null String Given to Regex.searchFrom"); - return _search(s,start,s.length()); - } - public boolean searchFrom(StringLike s,int start) { - if(s==null) - throw new NullPointerException("Null String Given to Regex.searchFrom"); - return _search(s,start,s.length()); - } - /** Search through a region of a String - for the first occurence of a match. */ - public boolean searchRegion(String s,int start,int end) { - if(s==null) - throw new NullPointerException("Null String Given to Regex.searchRegion"); - return _search(s,start,end); - } - /** Set this to change the default behavior of the "." pattern. - By default it now matches perl's behavior and fails to - match the '\n' character. */ - public static boolean dotDoesntMatchCR = true; - StringLike gFlags; - int gFlagto = 0; - boolean gFlag = false; - /** Set the 'g' flag */ - public void setGFlag(boolean b) { - gFlag = b; - } - /** Get the state of the 'g' flag. */ - public boolean getGFlag() { - return gFlag; - } - boolean sFlag = false; - /** Get the state of the sFlag */ - public boolean getSFlag() { - return sFlag; - } - boolean mFlag = false; - /** Get the state of the sFlag */ - public boolean getMFlag() { - return mFlag; - } - - final boolean _search(String s,int start,int end) { - return _search(new StringWrap(s),start,end); - } - final boolean _search(StringLike s,int start,int end) { - if(gFlag && gFlagto > 0 && gFlags!=null && s.unwrap()==gFlags.unwrap()) - start = gFlagto; - gFlags = null; - - Pthings pt=prep(s); - - int up = (minMatch == null ? end : end-minMatch.i); - - if(up < start && end >= start) up = start; - - if(skipper == null) { - for(int i=start;i<=up;i++) { - charsMatched_ = thePattern.matchAt(s,i,pt); - if(charsMatched_ >= 0) { - matchFrom_ = thePattern.mfrom; - marks = pt.marks; - gFlagto = matchFrom_+charsMatched_; - gFlags = s; - return didMatch_=true; - } - } - } else { - pt.no_check = true; - for(int i=start;i<=up;i++) { - i = skipper.find(src,i,up); - if(i<0) { - charsMatched_ = matchFrom_ = -1; - return didMatch_ = false; - } - charsMatched_ = thePattern.matchAt(s,i,pt); - if(charsMatched_ >= 0) { - matchFrom_ = thePattern.mfrom; - marks = pt.marks; - gFlagto = matchFrom_+charsMatched_; - gFlags = s; - return didMatch_=true; - } - } - } - return didMatch_=false; - } - /*final boolean _search(LongStringLike s,long start,long end) { - if(gFlag && gFlagto > 0 && s==gFlags) - start = gFlagto; - gFlags = null; - - Pthings pt=prep(s); - - int up = end;//(minMatch == null ? end : end-minMatch.i); - - if(up < start && end >= start) up = start; - - if(skipper == null) { - for(long i=start;i<=up;i++) { - charsMatched_ = thePattern.matchAt(s,i,pt); - if(charsMatched_ >= 0) { - matchFrom_ = thePattern.mfrom; - marks = pt.marks; - gFlagto = matchFrom_+charsMatched_; - return didMatch_=true; - } - } - } else { - pt.no_check = true; - for(long i=start;i<=up;i++) { - i = skipper.find(src,i,up); - if(i<0) { - charsMatched_ = matchFrom_ = -1; - return didMatch_ = false; - } - charsMatched_ = thePattern.matchAt(s,i,pt); - if(charsMatched_ >= 0) { - matchFrom_ = thePattern.mfrom; - marks = pt.marks; - gFlagto = matchFrom_+charsMatched_; - gFlags = s; - return didMatch_=true; - } else { - i = s.adjustIndex(i); - up = s.adjustEnd(i); - } - } - } - return didMatch_=false; - }*/ - - boolean _reverseSearch(String s,int start,int end) { - return _reverseSearch(new StringWrap(s),start,end); - } - boolean _reverseSearch(StringLike s,int start,int end) { - if(gFlag && gFlagto > 0 && s.unwrap()==gFlags.unwrap()) - end = gFlagto; - gFlags = null; - Pthings pt=prep(s); - for(int i=end;i>=start;i--) { - charsMatched_ = thePattern.matchAt(s,i,pt); - if(charsMatched_ >= 0) { - matchFrom_ = thePattern.mfrom; - marks = pt.marks; - gFlagto = matchFrom_-1; - gFlags = s; - return didMatch_=true; - } - } - return didMatch_=false; - } - - // This routine sets the cbits variable - // of class Pattern. Cbits is true for - // the bit corresponding to a character inside - // a set of quotes. - static StringLike lasts=null; - static BitSet lastbs=null; - static void setCbits(StringLike s,Pthings pt) { - if(s == lasts) { - pt.cbits = lastbs; - return; + +

+ Differences between this package and perl5:
+ The extended Pattern for setting flags, is now supported, + but the flags are different. "(?i)" tells the pattern to + ignore case, "(?Q)" sets the "dontMatchInQuotes" flag, and + "(?iQ)" sets them both. You can change the escape character. + The pattern

(?e=#)#d+
is the same as
\d+
, + but note that the sequence
(?e=#)
must occur + at the very beginning of the pattern. There may be other small + differences as well. I will either make my package conform + or note them as I become aware of them. +

+ This package supports additional patterns not in perl5: +

+ + + +
(?@())GroupThis matches all characters between + the '(' character and the balancing ')' character. Thus, it will + match "()" as well as "(())". The balancing characters are + arbitrary, thus (?@{}) matches on "{}" and "{{}}".
(?<1)BackupMoves the pointer backwards within the text. + This allows you to make a "look behind." It fails if it + attempts to move to a position before the beginning of the string. + "x(?<1)" is equivalent to "(?=x)". The number, 1 in this example, + is the number of characters to move backwards.
+
+ + @author Steven R. Brandt + @version package com.stevesoft.pat, release 1.5.3 + @see Pattern + */ +public class Regex + extends RegRes implements FilenameFilter +{ + /** BackRefOffset gives the identity number of the first + pattern. Version 1.0 used zero, version 1.1 uses 1 to be + more compatible with perl. */ + static int BackRefOffset = 1; + private static Pattern none = new NoPattern(); + Pattern thePattern = none; + patInt minMatch = new patInt(0); + + static Hashtable validators = new Hashtable(); + static + { + define("p", "(?>1)", new UnicodePunct()); + define("P", "(?>1)", new NUnicodePunct()); + define("s", "(?>1)", new UnicodeWhite()); + define("S", "(?>1)", new NUnicodeWhite()); + define("w", "(?>1)", new UnicodeW()); + define("W", "(?>1)", new NUnicodeW()); + define("d", "(?>1)", new UnicodeDigit()); + define("D", "(?>1)", new NUnicodeDigit()); + define("m", "(?>1)", new UnicodeMath()); + define("M", "(?>1)", new NUnicodeMath()); + define("c", "(?>1)", new UnicodeCurrency()); + define("C", "(?>1)", new NUnicodeCurrency()); + define("a", "(?>1)", new UnicodeAlpha()); + define("A", "(?>1)", new NUnicodeAlpha()); + define("uc", "(?>1)", new UnicodeUpper()); + define("lc", "(?>1)", new UnicodeLower()); + } + + /** Set the dontMatch in quotes flag. */ + public void setDontMatchInQuotes(boolean b) + { + dontMatchInQuotes = b; + } + + /** Find out if the dontMatchInQuotes flag is enabled. */ + public boolean getDontMatchInQuotes() + { + return dontMatchInQuotes; + } + + boolean dontMatchInQuotes = false; + + /** Set the state of the ignoreCase flag. If set to true, then + the pattern matcher will ignore case when searching for a + match. */ + public void setIgnoreCase(boolean b) + { + ignoreCase = b; + } + + /** Get the state of the ignoreCase flag. Returns true if we + are ignoring the case of the pattern, false otherwise. */ + public boolean getIgnoreCase() + { + return ignoreCase; + } + + boolean ignoreCase = false; + + static boolean defaultMFlag = false; + /** Set the default value of the m flag. If it + is set to true, then the MFlag will be on + for any regex search executed. */ + public static void setDefaultMFlag(boolean mFlag) + { + defaultMFlag = mFlag; + } + + /** Get the default value of the m flag. If it + is set to true, then the MFlag will be on + for any regex search executed. */ + public static boolean getDefaultMFlag() + { + return defaultMFlag; + } + + /** Initializes the object without a Pattern. To supply a Pattern + use compile(String s). + @see com.stevesoft.pat.Regex#compile(java.lang.String) + */ + public Regex() + {} + + /** Create and compile a Regex, but do not throw any exceptions. + If you wish to have exceptions thrown for syntax errors, + you must use the Regex(void) constructor to create the + Regex object, and then call the compile method. Therefore, you + should only call this method when you know your pattern is right. + I will probably become more like + @see com.stevesoft.pat.Regex#search(java.lang.String) + @see com.stevesoft.pat.Regex#compile(java.lang.String) + */ + public Regex(String s) + { + try + { + compile(s); + } + catch (RegSyntax rs) + {} + } + + ReplaceRule rep = null; + /** Create and compile both a Regex and a ReplaceRule. + @see com.stevesoft.pat.ReplaceRule + @see com.stevesoft.pat.Regex#compile(java.lang.String) + */ + public Regex(String s, String rp) + { + this(s); + rep = ReplaceRule.perlCode(rp); + } + + /** Create and compile a Regex, but give it the ReplaceRule + specified. This allows the user finer control of the + Replacement process, if that is desired. + @see com.stevesoft.pat.ReplaceRule + @see com.stevesoft.pat.Regex#compile(java.lang.String) + */ + public Regex(String s, ReplaceRule rp) + { + this(s); + rep = rp; + } + + /** Change the ReplaceRule of this Regex by compiling + a new one using String rp. */ + public void setReplaceRule(String rp) + { + rep = ReplaceRule.perlCode(rp); + repr = null; // Clear Replacer history + } + + /** Change the ReplaceRule of this Regex to rp. */ + public void setReplaceRule(ReplaceRule rp) + { + rep = rp; + } + + /** Test to see if a custom defined rule exists. + @see com.stevesoft.pat#define(java.lang.String,java.lang.String,Validator) + */ + public static boolean isDefined(String nm) + { + return validators.get(nm) != null; + } + + /** Removes a custom defined rule. + @see com.stevesoft.pat#define(java.lang.String,java.lang.String,Validator) + */ + public static void undefine(String nm) + { + validators.remove(nm); + } + + /** Defines a method to create a new rule. See test/deriv2.java + and test/deriv3.java for examples of how to use it. */ + public static void define(String nm, String pat, Validator v) + { + v.pattern = pat; + validators.put(nm, v); + } + + /** Defines a shorthand for a pattern. The pattern will be + invoked by a string that has the form "(??"+nm+")". + */ + public static void define(String nm, String pat) + { + validators.put(nm, pat); + } + + /** Get the current ReplaceRule. */ + public ReplaceRule getReplaceRule() + { + return rep; + } + + Replacer repr = null; + final Replacer _getReplacer() + { + return repr == null ? repr = new Replacer() : repr; + } + + public Replacer getReplacer() + { + if (repr == null) + { + repr = new Replacer(); + } + repr.rh.me = this; + repr.rh.prev = null; + return repr; + } + + /** Replace the first occurence of this pattern in String s + according to the ReplaceRule. + @see com.stevesoft.pat.ReplaceRule + @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceFirst(String s) + { + return _getReplacer().replaceFirstRegion(s, this, 0, s.length()).toString(); + } + + /** Replace the first occurence of this pattern in String s + beginning with position pos according to the ReplaceRule. + @see com.stevesoft.pat.ReplaceRule + @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceFirstFrom(String s, int pos) + { + return _getReplacer().replaceFirstRegion(s, this, pos, s.length()).toString(); + } + + /** Replace the first occurence of this pattern in String s + beginning with position start and ending with end + according to the ReplaceRule. + @see com.stevesoft.pat.ReplaceRule + @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceFirstRegion(String s, int start, int end) + { + return _getReplacer().replaceFirstRegion(s, this, start, end).toString(); + } + + /** Replace all occurences of this pattern in String s + according to the ReplaceRule. + @see com.stevesoft.pat.ReplaceRule + @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceAll(String s) + { + return _getReplacer().replaceAllRegion(s, this, 0, s.length()).toString(); + } + + public StringLike replaceAll(StringLike s) + { + return _getReplacer().replaceAllRegion(s, this, 0, s.length()); + } + + /** Replace all occurences of this pattern in String s + beginning with position pos according to the ReplaceRule. + @see com.stevesoft.pat.ReplaceRule + @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceAllFrom(String s, int pos) + { + return _getReplacer().replaceAllRegion(s, this, pos, s.length()).toString(); + } + + /** Replace all occurences of this pattern in String s + beginning with position start and ending with end + according to the ReplaceRule. + @see com.stevesoft.pat.ReplaceRule + @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceAllRegion(String s, int start, int end) + { + return _getReplacer().replaceAllRegion(s, this, start, end).toString(); + } + + /** Essentially clones the Regex object */ + public Regex(Regex r) + { + super( (RegRes) r); + dontMatchInQuotes = r.dontMatchInQuotes; + esc = r.esc; + ignoreCase = r.ignoreCase; + gFlag = r.gFlag; + if (r.rep == null) + { + rep = null; + } + else + { + rep = (ReplaceRule) r.rep.clone(); + } + /* try { + compile(r.toString()); + } catch(RegSyntax r_) {} */ + thePattern = r.thePattern.clone(new Hashtable()); + minMatch = r.minMatch; + skipper = r.skipper; + } + + /** By default, + the escape character is the backslash, but you can + make it anything you want by setting this variable. */ + public char esc = Pattern.ESC; + /** This method compiles a regular expression, making it + possible to call the search or matchAt methods. + @exception com.stevesoft.pat.RegSyntax + is thrown if a syntax error is encountered + in the pattern. + For example, "x{3,1}" or "*a" are not valid + patterns. + @see com.stevesoft.pat.Regex#search + @see com.stevesoft.pat.Regex#matchAt + */ + public void compile(String prepat) + throws RegSyntax + { + String postpat = parsePerl.codify(prepat, true); + String pat = postpat == null ? prepat : postpat; + minMatch = null; + ignoreCase = false; + dontMatchInQuotes = false; + Rthings mk = new Rthings(this); + int offset = mk.val; + String newpat = pat; + thePattern = none; + p = null; + or = null; + minMatch = new patInt(0); + StrPos sp = new StrPos(pat, 0); + if (sp.incMatch("(?e=")) + { + char newEsc = sp.c; + sp.inc(); + if (sp.match(')')) + { + newpat = reEscape(pat.substring(6), + newEsc, Pattern.ESC); + } + } + else if (esc != Pattern.ESC) + { + newpat = reEscape(pat, esc, Pattern.ESC); + } + thePattern = _compile(newpat, mk); + numSubs_ = mk.val - offset; + mk.set(this); + } + + /* If a Regex is compared against a Regex, a check is + done to see that the patterns are equal as well as + the most recent match. If a Regex is compare with + a RegRes, only the result of the most recent match + is compared. */ + public boolean equals(Object o) + { + if (o instanceof Regex) + { + if (toString().equals(o.toString())) + { + return super.equals(o); + } + else + { + return false; + } + } + else + { + return super.equals(o); + } + } + + /** A clone by any other name would smell as sweet. */ + public Object clone() + { + return new Regex(this); + } + + /** Return a clone of the underlying RegRes object. */ + public RegRes result() + { + return (RegRes)super.clone(); + } + + // prep sets global variables of class + // Pattern so that it can access them + // during an attempt at a match + Pthings pt = new Pthings(); + final Pthings prep(StringLike s) + { + //if(gFlag) + pt.lastPos = matchedTo(); + if (pt.lastPos < 0) + { + pt.lastPos = 0; + } + if ( (s == null ? null : s.unwrap()) != (src == null ? null : s.unwrap())) + { + pt.lastPos = 0; + } + src = s; + pt.dotDoesntMatchCR = dotDoesntMatchCR && (!sFlag); + pt.mFlag = (mFlag | defaultMFlag); + pt.ignoreCase = ignoreCase; + pt.no_check = false; + if (pt.marks != null) + { + for (int i = 0; i < pt.marks.length; i++) + { + pt.marks[i] = -1; + } + } + pt.marks = null; + pt.nMarks = numSubs_; + pt.src = s; + if (dontMatchInQuotes) + { + setCbits(s, pt); + } + else + { + pt.cbits = null; + } + return pt; + } + + /** Attempt to match a Pattern beginning + at a specified location within the string. + @see com.stevesoft.pat.Regex#search + */ + public boolean matchAt(String s, int start_pos) + { + return _search(s, start_pos, start_pos); + } + + /** Attempt to match a Pattern beginning + at a specified location within the StringLike. + @see com.stevesoft.pat.Regex#search + */ + public boolean matchAt(StringLike s, int start_pos) + { + return _search(s, start_pos, start_pos); + } + + /** Search through a String for the first + occurrence of a match. + @see com.stevesoft.pat.Regex#searchFrom + @see com.stevesoft.pat.Regex#matchAt + */ + public boolean search(String s) + { + if (s == null) + { + throw new NullPointerException("Null String Given to Regex.search"); + } + return _search(s, 0, s.length()); + } + + public boolean search(StringLike sl) + { + if (sl == null) + { + throw new NullPointerException("Null StringLike Given to Regex.search"); + } + return _search(sl, 0, sl.length()); + } + + public boolean reverseSearch(String s) + { + if (s == null) + { + throw new NullPointerException("Null String Given to Regex.reverseSearch"); + } + return _reverseSearch(s, 0, s.length()); + } + + public boolean reverseSearch(StringLike sl) + { + if (sl == null) + { + throw new NullPointerException( + "Null StringLike Given to Regex.reverseSearch"); + } + return _reverseSearch(sl, 0, sl.length()); + } + + /** Search through a String for the first + occurence of a match, but start at position
start
*/ + public boolean searchFrom(String s, int start) + { + if (s == null) + { + throw new NullPointerException("Null String Given to Regex.searchFrom"); + } + return _search(s, start, s.length()); + } + + public boolean searchFrom(StringLike s, int start) + { + if (s == null) + { + throw new NullPointerException("Null String Given to Regex.searchFrom"); + } + return _search(s, start, s.length()); + } + + /** Search through a region of a String + for the first occurence of a match. */ + public boolean searchRegion(String s, int start, int end) + { + if (s == null) + { + throw new NullPointerException("Null String Given to Regex.searchRegion"); + } + return _search(s, start, end); + } + + /** Set this to change the default behavior of the "." pattern. + By default it now matches perl's behavior and fails to + match the '\n' character. */ + public static boolean dotDoesntMatchCR = true; + StringLike gFlags; + int gFlagto = 0; + boolean gFlag = false; + /** Set the 'g' flag */ + public void setGFlag(boolean b) + { + gFlag = b; + } + + /** Get the state of the 'g' flag. */ + public boolean getGFlag() + { + return gFlag; + } + + boolean sFlag = false; + /** Get the state of the sFlag */ + public boolean getSFlag() + { + return sFlag; + } + + boolean mFlag = false; + /** Get the state of the sFlag */ + public boolean getMFlag() + { + return mFlag; + } + + final boolean _search(String s, int start, int end) + { + return _search(new StringWrap(s), start, end); + } + + final boolean _search(StringLike s, int start, int end) + { + if (gFlag && gFlagto > 0 && gFlags != null && s.unwrap() == gFlags.unwrap()) + { + start = gFlagto; + } + gFlags = null; + + Pthings pt = prep(s); + + int up = (minMatch == null ? end : end - minMatch.i); + + if (up < start && end >= start) + { + up = start; + } + + if (skipper == null) + { + for (int i = start; i <= up; i++) + { + charsMatched_ = thePattern.matchAt(s, i, pt); + if (charsMatched_ >= 0) + { + matchFrom_ = thePattern.mfrom; + marks = pt.marks; + gFlagto = matchFrom_ + charsMatched_; + gFlags = s; + return didMatch_ = true; } - BitSet bs = new BitSet(s.length()); - char qc = ' '; - boolean setBit = false; - for(int i=0;i= 0) + { + matchFrom_ = thePattern.mfrom; + marks = pt.marks; + gFlagto = matchFrom_ + charsMatched_; + gFlags = s; + return didMatch_ = true; } + } } - /** Only needed for creating your own extensions of - Regex. This method adds the next Pattern in the chain - of patterns or sets the Pattern if it is the first call. */ - protected void add(Pattern p2) { - if(p == null) - p = p2; - else { - p.add(p2); - p2 = p; + return didMatch_ = false; + } + + /*final boolean _search(LongStringLike s,long start,long end) { + if(gFlag && gFlagto > 0 && s==gFlags) + start = gFlagto; + gFlags = null; + + Pthings pt=prep(s); + + int up = end;//(minMatch == null ? end : end-minMatch.i); + + if(up < start && end >= start) up = start; + + if(skipper == null) { + for(long i=start;i<=up;i++) { + charsMatched_ = thePattern.matchAt(s,i,pt); + if(charsMatched_ >= 0) { + matchFrom_ = thePattern.mfrom; + marks = pt.marks; + gFlagto = matchFrom_+charsMatched_; + return didMatch_=true; + } + } + } else { + pt.no_check = true; + for(long i=start;i<=up;i++) { + i = skipper.find(src,i,up); + if(i<0) { + charsMatched_ = matchFrom_ = -1; + return didMatch_ = false; + } + charsMatched_ = thePattern.matchAt(s,i,pt); + if(charsMatched_ >= 0) { + matchFrom_ = thePattern.mfrom; + marks = pt.marks; + gFlagto = matchFrom_+charsMatched_; + gFlags = s; + return didMatch_=true; + } else { + i = s.adjustIndex(i); + up = s.adjustEnd(i); + } + } + } + return didMatch_=false; + }*/ + + boolean _reverseSearch(String s, int start, int end) + { + return _reverseSearch(new StringWrap(s), start, end); + } + + boolean _reverseSearch(StringLike s, int start, int end) + { + if (gFlag && gFlagto > 0 && s.unwrap() == gFlags.unwrap()) + { + end = gFlagto; + } + gFlags = null; + Pthings pt = prep(s); + for (int i = end; i >= start; i--) + { + charsMatched_ = thePattern.matchAt(s, i, pt); + if (charsMatched_ >= 0) + { + matchFrom_ = thePattern.mfrom; + marks = pt.marks; + gFlagto = matchFrom_ - 1; + gFlags = s; + return didMatch_ = true; + } + } + return didMatch_ = false; + } + + // This routine sets the cbits variable + // of class Pattern. Cbits is true for + // the bit corresponding to a character inside + // a set of quotes. + static StringLike lasts = null; + static BitSet lastbs = null; + static void setCbits(StringLike s, Pthings pt) + { + if (s == lasts) + { + pt.cbits = lastbs; + return; + } + BitSet bs = new BitSet(s.length()); + char qc = ' '; + boolean setBit = false; + for (int i = 0; i < s.length(); i++) + { + if (setBit) + { + bs.set(i); + } + char c = s.charAt(i); + if (!setBit && c == '"') + { + qc = c; + setBit = true; + bs.set(i); + } + else if (!setBit && c == '\'') + { + qc = c; + setBit = true; + bs.set(i); + } + else if (setBit && c == qc) + { + setBit = false; + } + else if (setBit && c == '\\' && i + 1 < s.length()) + { + i++; + if (setBit) + { + bs.set(i); } + } } + pt.cbits = lastbs = bs; + lasts = s; + } - /** You only need to use this method if you are creating - your own extentions to Regex. - compile1 compiles one Pattern element, it can be - over-ridden to allow the Regex compiler to understand - new syntax. See deriv.java for an example. This routine - is the heart of class Regex. Rthings has one integer - member called intValue, it is used to keep track of the number - of ()'s in the Pattern. - @exception com.stevesoft.pat.RegSyntax is thrown when a nonsensensical - pattern is supplied. For example, a pattern beginning - with *. */ - protected void compile1(StrPos sp,Rthings mk) throws RegSyntax { - if(sp.match('[')) { - sp.inc(); - add(matchBracket(sp)); - } else if(sp.match('|')) { - if(or == null) - or = new Or(); - if(p == null) p=new NullPattern(); - or.addOr(p); - p = null; - } else if(sp.incMatch("(?<")) { - patInt i = sp.getPatInt(); - if(i==null) RegSyntaxError.endItAll("No int after (?<"); - add(new Backup(i.intValue())); - if(!sp.match(')')) RegSyntaxError.endItAll("No ) after (?<"); - } else if(sp.incMatch("(?>")) { - patInt i = sp.getPatInt(); - if(i==null) RegSyntaxError.endItAll("No int after (?>"); - add(new Backup(-i.intValue())); - if(!sp.match(')')) RegSyntaxError.endItAll("No ) after (?<"); - } else if(sp.incMatch("(?@")) { - char op = sp.c; - sp.inc(); - char cl = sp.c; - sp.inc(); - if(!sp.match(')')) - RegSyntaxError.endItAll( - "(?@ does not have closing paren"); - add(new Group(op,cl)); - } else if(sp.incMatch("(?#")) { - while(!sp.match(')')) - sp.inc(); - } else if(sp.dontMatch && sp.c == 'w') { - //Regex r = new Regex(); - //r._compile("[a-zA-Z0-9_]",mk); - //add(new Goop("\\w",r.thePattern)); - Bracket b = new Bracket(false); - b.addOr(new Range('a','z')); - b.addOr(new Range('A','Z')); - b.addOr(new Range('0','9')); - b.addOr(new oneChar('_')); - add(b); - } else if(sp.dontMatch && sp.c == 'G') { - add(new BackG()); - } else if(sp.dontMatch && sp.c == 's') { - //Regex r = new Regex(); - //r._compile("[ \t\n\r\b]",mk); - //add(new Goop("\\s",r.thePattern)); - Bracket b = new Bracket(false); - b.addOr(new oneChar((char)32)); - b.addOr(new Range((char)8,(char)10)); - b.addOr(new oneChar((char)13)); - add(b); - } else if(sp.dontMatch && sp.c == 'd') { - //Regex r = new Regex(); - //r._compile("[0-9]",mk); - //add(new Goop("\\d",r.thePattern)); - Range digit = new Range('0','9'); - digit.printBrackets = true; - add(digit); - } else if(sp.dontMatch && sp.c == 'W') { - //Regex r = new Regex(); - //r._compile("[^a-zA-Z0-9_]",mk); - //add(new Goop("\\W",r.thePattern)); - Bracket b = new Bracket(true); - b.addOr(new Range('a','z')); - b.addOr(new Range('A','Z')); - b.addOr(new Range('0','9')); - b.addOr(new oneChar('_')); - add(b); - } else if(sp.dontMatch && sp.c == 'S') { - //Regex r = new Regex(); - //r._compile("[^ \t\n\r\b]",mk); - //add(new Goop("\\S",r.thePattern)); - Bracket b = new Bracket(true); - b.addOr(new oneChar((char)32)); - b.addOr(new Range((char)8,(char)10)); - b.addOr(new oneChar((char)13)); - add(b); - } else if(sp.dontMatch && sp.c == 'D') { - //Regex r = new Regex(); - //r._compile("[^0-9]",mk); - //add(new Goop("\\D",r.thePattern)); - Bracket b = new Bracket(true); - b.addOr(new Range('0','9')); - add(b); - } else if(sp.dontMatch && sp.c == 'B') { - Regex r = new Regex(); - r._compile("(?!"+back_slash+"b)",mk); - add(r.thePattern); - } else if(isOctalString(sp)) { - int d = sp.c - '0'; - sp.inc(); - d = 8*d + sp.c - '0'; - StrPos sp2 = new StrPos(sp); - sp2.inc(); - if(isOctalDigit(sp2,false)) { - sp.inc(); - d = 8*d + sp.c - '0'; - } - add(new oneChar((char)d)); - } else if(sp.dontMatch && sp.c >= '1' && sp.c <= '9') { - int iv = sp.c-'0'; - StrPos s2 = new StrPos(sp); - s2.inc(); - if(!s2.dontMatch && s2.c >= '0' && s2.c <= '9') { - iv = 10*iv+(s2.c-'0'); - sp.inc(); - } - add(new BackMatch(iv)); - } else if(sp.dontMatch && sp.c == 'b') { - add(new Boundary()); - } else if(sp.match('\b')) { - add(new Boundary()); - } else if(sp.match('$')) { - add(new End(true)); - } else if(sp.dontMatch && sp.c == 'Z') { - add(new End(false)); - } else if(sp.match('.')) { - add(new Any()); - } else if(sp.incMatch("(??")) { - StringBuffer sb = new StringBuffer(); - StringBuffer sb2 = new StringBuffer(); - while(!sp.match(')') && !sp.match(':')) { - sb.append(sp.c); - sp.inc(); - } - if(sp.incMatch(":")) { - while(!sp.match(')')) { - sb2.append(sp.c); - sp.inc(); - } - } - String sbs = sb.toString(); - if(validators.get(sbs) instanceof String) { - String pat = (String)validators.get(sbs); - Regex r = newRegex(); - Rthings rth = new Rthings(this); - rth.noBackRefs = true; - r._compile(pat,rth); - add(r.thePattern); - } else { - Custom cm = new Custom(sb.toString()); - if(cm.v != null) { - Validator v2 = cm.v.arg(sb2.toString()); - if(v2 != null) { - v2.argsave = sb2.toString(); - String p = cm.v.pattern; - cm.v = v2; - v2.pattern = p; - } - Regex r = newRegex(); - Rthings rth = new Rthings(this); - rth.noBackRefs = true; - r._compile(cm.v.pattern,rth); - cm.sub = r.thePattern; - cm.sub.add(new CustomEndpoint(cm)); - cm.sub.setParent(cm); - add(cm); - } - } - } else if(sp.match('(')) { - mk.parenLevel++; - Regex r = newRegex(); - // r.or = new Or(); - sp.inc(); - if(sp.incMatch("?:")) { - r.or = new Or(); - } else if(sp.incMatch("?=")) { - r.or = new lookAhead(false); - } else if(sp.incMatch("?!")) { - r.or = new lookAhead(true); - } else if(sp.match('?')) { - sp.inc(); - do { - if(sp.c=='i')mk.ignoreCase = true; - if(sp.c=='Q')mk.dontMatchInQuotes = true; - if(sp.c=='o')mk.optimizeMe = true; - if(sp.c=='g')mk.gFlag = true; - if(sp.c=='s')mk.sFlag = true; - if(sp.c=='m')mk.mFlag = true; - sp.inc(); - } while(!sp.match(')') && !sp.eos); - r = null; - mk.parenLevel--; - if(sp.eos) //throw new RegSyntax - RegSyntaxError.endItAll("Unclosed ()"); - } else { // just ordinary parenthesis - r.or = mk.noBackRefs ? new Or() : new OrMark(mk.val++); - } - if(r != null) add(r._compile(sp,mk)); - } else if(sp.match('^')) { - add(new Start(true)); - } else if(sp.dontMatch && sp.c=='A') { - add(new Start(false)); - } else if(sp.match('*')) { - addMulti(new patInt(0),new patInf()); - } else if(sp.match('+')) { - addMulti(new patInt(1),new patInf()); - } else if(sp.match('?')) { - addMulti(new patInt(0),new patInt(1)); - } else if(sp.match('{')) { - boolean bad = false; - StrPos sp2 = new StrPos(sp); - //StringBuffer sb = new StringBuffer(); - sp.inc(); - patInt i1 = sp.getPatInt(); - patInt i2 = null; - if(sp.match('}')) { - i2 = i1; - } else { - if(!sp.match(','))/* - RegSyntaxError.endItAll( - "String \"{"+i2+ - "\" should be followed with , or }");*/ - bad = true; - sp.inc(); - if(sp.match('}')) - i2 = new patInf(); - else - i2 = sp.getPatInt(); - } - if(i1 == null || i2 == null) /* - throw new RegSyntax("Badly formatted Multi: " - +"{"+i1+","+i2+"}"); */ bad = true; - if(bad) { - sp.dup(sp2); - add(new oneChar(sp.c)); - } else - addMulti(i1,i2); - } else if(sp.escMatch('x') && next2Hex(sp)) { - sp.inc(); - int d = getHexDigit(sp); - sp.inc(); - d = 16*d + getHexDigit(sp); - add(new oneChar((char)d)); - } else if(sp.escMatch('c')) { - sp.inc(); - if(sp.c < Ctrl.cmap.length) - add(new oneChar(Ctrl.cmap[sp.c])); - else - add(new oneChar(sp.c)); - } else if(sp.escMatch('f')) { - add(new oneChar((char)12)); - } else if(sp.escMatch('a')) { - add(new oneChar((char)7)); - } else if(sp.escMatch('t')) { - add(new oneChar('\t')); - } else if(sp.escMatch('n')) { - add(new oneChar('\n')); - } else if(sp.escMatch('r')) { - add(new oneChar('\r')); - } else if(sp.escMatch('b')) { - add(new oneChar('\b')); - } else if(sp.escMatch('e')) { - add(new oneChar((char)27)); - } else { - add(new oneChar(sp.c)); - if(sp.match(')')) - RegSyntaxError.endItAll("Unmatched right paren in pattern"); - } + // Wanted user to over-ride this in alpha version, + // but it wasn't really necessary because of this trick: + Regex newRegex() + { + try + { + return (Regex) getClass().newInstance(); + } + catch (InstantiationException ie) + { + return null; + } + catch (IllegalAccessException iae) + { + return null; } + } - // compiles all Pattern elements, internal method - private Pattern _compile(String pat,Rthings mk) throws RegSyntax { - minMatch = null; - sFlag = mFlag = ignoreCase = gFlag = false; - StrPos sp = new StrPos(pat,0); - thePattern = _compile(sp,mk); - pt.marks = null; - return thePattern; + /** Only needed for creating your own extensions of + Regex. This method adds the next Pattern in the chain + of patterns or sets the Pattern if it is the first call. */ + protected void add(Pattern p2) + { + if (p == null) + { + p = p2; + } + else + { + p.add(p2); + p2 = p; } + } - Pattern p = null; - Or or = null; - Pattern _compile(StrPos sp,Rthings mk) throws RegSyntax { - while(!(sp.eos || (or != null && sp.match(')')) )) { - compile1(sp,mk); - sp.inc(); + /** You only need to use this method if you are creating + your own extentions to Regex. + compile1 compiles one Pattern element, it can be + over-ridden to allow the Regex compiler to understand + new syntax. See deriv.java for an example. This routine + is the heart of class Regex. Rthings has one integer + member called intValue, it is used to keep track of the number + of ()'s in the Pattern. + @exception com.stevesoft.pat.RegSyntax is thrown when a nonsensensical + pattern is supplied. For example, a pattern beginning + with *. */ + protected void compile1(StrPos sp, Rthings mk) + throws RegSyntax + { + if (sp.match('[')) + { + sp.inc(); + add(matchBracket(sp)); + } + else if (sp.match('|')) + { + if (or == null) + { + or = new Or(); + } + if (p == null) + { + p = new NullPattern(); + } + or.addOr(p); + p = null; + } + else if (sp.incMatch("(?<")) + { + patInt i = sp.getPatInt(); + if (i == null) + { + RegSyntaxError.endItAll("No int after (?<"); + } + add(new Backup(i.intValue())); + if (!sp.match(')')) + { + RegSyntaxError.endItAll("No ) after (?<"); + } + } + else if (sp.incMatch("(?>")) + { + patInt i = sp.getPatInt(); + if (i == null) + { + RegSyntaxError.endItAll("No int after (?>"); + } + add(new Backup( -i.intValue())); + if (!sp.match(')')) + { + RegSyntaxError.endItAll("No ) after (?<"); + } + } + else if (sp.incMatch("(?@")) + { + char op = sp.c; + sp.inc(); + char cl = sp.c; + sp.inc(); + if (!sp.match(')')) + { + RegSyntaxError.endItAll( + "(?@ does not have closing paren"); + } + add(new Group(op, cl)); + } + else if (sp.incMatch("(?#")) + { + while (!sp.match(')')) + { + sp.inc(); + } + } + else if (sp.dontMatch && sp.c == 'w') + { + //Regex r = new Regex(); + //r._compile("[a-zA-Z0-9_]",mk); + //add(new Goop("\\w",r.thePattern)); + Bracket b = new Bracket(false); + b.addOr(new Range('a', 'z')); + b.addOr(new Range('A', 'Z')); + b.addOr(new Range('0', '9')); + b.addOr(new oneChar('_')); + add(b); + } + else if (sp.dontMatch && sp.c == 'G') + { + add(new BackG()); + } + else if (sp.dontMatch && sp.c == 's') + { + //Regex r = new Regex(); + //r._compile("[ \t\n\r\b]",mk); + //add(new Goop("\\s",r.thePattern)); + Bracket b = new Bracket(false); + b.addOr(new oneChar( (char) 32)); + b.addOr(new Range( (char) 8, (char) 10)); + b.addOr(new oneChar( (char) 13)); + add(b); + } + else if (sp.dontMatch && sp.c == 'd') + { + //Regex r = new Regex(); + //r._compile("[0-9]",mk); + //add(new Goop("\\d",r.thePattern)); + Range digit = new Range('0', '9'); + digit.printBrackets = true; + add(digit); + } + else if (sp.dontMatch && sp.c == 'W') + { + //Regex r = new Regex(); + //r._compile("[^a-zA-Z0-9_]",mk); + //add(new Goop("\\W",r.thePattern)); + Bracket b = new Bracket(true); + b.addOr(new Range('a', 'z')); + b.addOr(new Range('A', 'Z')); + b.addOr(new Range('0', '9')); + b.addOr(new oneChar('_')); + add(b); + } + else if (sp.dontMatch && sp.c == 'S') + { + //Regex r = new Regex(); + //r._compile("[^ \t\n\r\b]",mk); + //add(new Goop("\\S",r.thePattern)); + Bracket b = new Bracket(true); + b.addOr(new oneChar( (char) 32)); + b.addOr(new Range( (char) 8, (char) 10)); + b.addOr(new oneChar( (char) 13)); + add(b); + } + else if (sp.dontMatch && sp.c == 'D') + { + //Regex r = new Regex(); + //r._compile("[^0-9]",mk); + //add(new Goop("\\D",r.thePattern)); + Bracket b = new Bracket(true); + b.addOr(new Range('0', '9')); + add(b); + } + else if (sp.dontMatch && sp.c == 'B') + { + Regex r = new Regex(); + r._compile("(?!" + back_slash + "b)", mk); + add(r.thePattern); + } + else if (isOctalString(sp)) + { + int d = sp.c - '0'; + sp.inc(); + d = 8 * d + sp.c - '0'; + StrPos sp2 = new StrPos(sp); + sp2.inc(); + if (isOctalDigit(sp2, false)) + { + sp.inc(); + d = 8 * d + sp.c - '0'; + } + add(new oneChar( (char) d)); + } + else if (sp.dontMatch && sp.c >= '1' && sp.c <= '9') + { + int iv = sp.c - '0'; + StrPos s2 = new StrPos(sp); + s2.inc(); + if (!s2.dontMatch && s2.c >= '0' && s2.c <= '9') + { + iv = 10 * iv + (s2.c - '0'); + sp.inc(); + } + add(new BackMatch(iv)); + } + else if (sp.dontMatch && sp.c == 'b') + { + add(new Boundary()); + } + else if (sp.match('\b')) + { + add(new Boundary()); + } + else if (sp.match('$')) + { + add(new End(true)); + } + else if (sp.dontMatch && sp.c == 'Z') + { + add(new End(false)); + } + else if (sp.match('.')) + { + add(new Any()); + } + else if (sp.incMatch("(??")) + { + StringBuffer sb = new StringBuffer(); + StringBuffer sb2 = new StringBuffer(); + while (!sp.match(')') && !sp.match(':')) + { + sb.append(sp.c); + sp.inc(); + } + if (sp.incMatch(":")) + { + while (!sp.match(')')) + { + sb2.append(sp.c); + sp.inc(); + } + } + String sbs = sb.toString(); + if (validators.get(sbs) instanceof String) + { + String pat = (String) validators.get(sbs); + Regex r = newRegex(); + Rthings rth = new Rthings(this); + rth.noBackRefs = true; + r._compile(pat, rth); + add(r.thePattern); + } + else + { + Custom cm = new Custom(sb.toString()); + if (cm.v != null) + { + Validator v2 = cm.v.arg(sb2.toString()); + if (v2 != null) + { + v2.argsave = sb2.toString(); + String p = cm.v.pattern; + cm.v = v2; + v2.pattern = p; + } + Regex r = newRegex(); + Rthings rth = new Rthings(this); + rth.noBackRefs = true; + r._compile(cm.v.pattern, rth); + cm.sub = r.thePattern; + cm.sub.add(new CustomEndpoint(cm)); + cm.sub.setParent(cm); + add(cm); + } + } + } + else if (sp.match('(')) + { + mk.parenLevel++; + Regex r = newRegex(); + // r.or = new Or(); + sp.inc(); + if (sp.incMatch("?:")) + { + r.or = new Or(); + } + else if (sp.incMatch("?=")) + { + r.or = new lookAhead(false); + } + else if (sp.incMatch("?!")) + { + r.or = new lookAhead(true); + } + else if (sp.match('?')) + { + sp.inc(); + do + { + if (sp.c == 'i') + { + mk.ignoreCase = true; + } + if (sp.c == 'Q') + { + mk.dontMatchInQuotes = true; + } + if (sp.c == 'o') + { + mk.optimizeMe = true; + } + if (sp.c == 'g') + { + mk.gFlag = true; + } + if (sp.c == 's') + { + mk.sFlag = true; + } + if (sp.c == 'm') + { + mk.mFlag = true; + } + sp.inc(); + } + while (!sp.match(')') && !sp.eos); + r = null; + mk.parenLevel--; + if (sp.eos) //throw new RegSyntax + { + RegSyntaxError.endItAll("Unclosed ()"); + } + } + else + { // just ordinary parenthesis + r.or = mk.noBackRefs ? new Or() : new OrMark(mk.val++); + } + if (r != null) + { + add(r._compile(sp, mk)); + } + } + else if (sp.match('^')) + { + add(new Start(true)); + } + else if (sp.dontMatch && sp.c == 'A') + { + add(new Start(false)); + } + else if (sp.match('*')) + { + addMulti(new patInt(0), new patInf()); + } + else if (sp.match('+')) + { + addMulti(new patInt(1), new patInf()); + } + else if (sp.match('?')) + { + addMulti(new patInt(0), new patInt(1)); + } + else if (sp.match('{')) + { + boolean bad = false; + StrPos sp2 = new StrPos(sp); + //StringBuffer sb = new StringBuffer(); + sp.inc(); + patInt i1 = sp.getPatInt(); + patInt i2 = null; + if (sp.match('}')) + { + i2 = i1; + } + else + { + if (!sp.match(',')) /* + { + RegSyntaxError.endItAll( + "String \"{"+i2+ + "\" should be followed with , or }");*/ + bad = true; + } + sp.inc(); + if (sp.match('}')) + { + i2 = new patInf(); } - if(sp.match(')')) mk.parenLevel--; - else if(sp.eos && mk.parenLevel != 0) { - RegSyntaxError.endItAll("Unclosed Parenthesis! lvl="+mk.parenLevel); - } if(or != null) { - if(p == null) p = new NullPattern(); - or.addOr(p); - return or; + else + { + i2 = sp.getPatInt(); } - return p==null ? new NullPattern() : p; + } + if (i1 == null || i2 == null) /* + { + throw new RegSyntax("Badly formatted Multi: " + +"{"+i1+","+i2+"}"); */bad = true; + } + if (bad) + { + sp.dup(sp2); + add(new oneChar(sp.c)); + } + else + { + addMulti(i1, i2); + } + } + else if (sp.escMatch('x') && next2Hex(sp)) + { + sp.inc(); + int d = getHexDigit(sp); + sp.inc(); + d = 16 * d + getHexDigit(sp); + add(new oneChar( (char) d)); + } + else if (sp.escMatch('c')) + { + sp.inc(); + if (sp.c < Ctrl.cmap.length) + { + add(new oneChar(Ctrl.cmap[sp.c])); + } + else + { + add(new oneChar(sp.c)); + } + } + else if (sp.escMatch('f')) + { + add(new oneChar( (char) 12)); + } + else if (sp.escMatch('a')) + { + add(new oneChar( (char) 7)); + } + else if (sp.escMatch('t')) + { + add(new oneChar('\t')); + } + else if (sp.escMatch('n')) + { + add(new oneChar('\n')); + } + else if (sp.escMatch('r')) + { + add(new oneChar('\r')); + } + else if (sp.escMatch('b')) + { + add(new oneChar('\b')); + } + else if (sp.escMatch('e')) + { + add(new oneChar( (char) 27)); + } + else + { + add(new oneChar(sp.c)); + if (sp.match(')')) + { + RegSyntaxError.endItAll("Unmatched right paren in pattern"); + } } + } - // add a multi object to the end of the chain - // which applies to the last object - void addMulti(patInt i1,patInt i2) throws RegSyntax { - Pattern last,last2; - for(last = p;last != null && last.next != null;last=last.next) - ; - if(last == null || last == p) - last2 = null; - else - for(last2 = p;last2.next != last;last2=last2.next) - ; - if(last instanceof Multi && i1.intValue()==0 && - i2.intValue()==1) - ((Multi)last).matchFewest = true; - else if(last instanceof FastMulti && i1.intValue()==0 && - i2.intValue()==1) - ((FastMulti)last).matchFewest = true; - else if(last instanceof DotMulti && i1.intValue()==0 && - i2.intValue()==1) - ((DotMulti)last).matchFewest = true; - else if(last instanceof Multi - || last instanceof DotMulti - || last instanceof FastMulti) - throw new RegSyntax("Syntax error."); - else if(last2 == null) - p = mkMulti(i1,i2,p); + // compiles all Pattern elements, internal method + private Pattern _compile(String pat, Rthings mk) + throws RegSyntax + { + minMatch = null; + sFlag = mFlag = ignoreCase = gFlag = false; + StrPos sp = new StrPos(pat, 0); + thePattern = _compile(sp, mk); + pt.marks = null; + return thePattern; + } + + Pattern p = null; + Or or = null; + Pattern _compile(StrPos sp, Rthings mk) + throws RegSyntax + { + while (! (sp.eos || (or != null && sp.match(')')))) + { + compile1(sp, mk); + sp.inc(); + } + if (sp.match(')')) + { + mk.parenLevel--; + } + else if (sp.eos && mk.parenLevel != 0) + { + RegSyntaxError.endItAll("Unclosed Parenthesis! lvl=" + mk.parenLevel); + } + if (or != null) + { + if (p == null) + { + p = new NullPattern(); + } + or.addOr(p); + return or; + } + return p == null ? new NullPattern() : p; + } + + // add a multi object to the end of the chain + // which applies to the last object + void addMulti(patInt i1, patInt i2) + throws RegSyntax + { + Pattern last, last2; + for (last = p; last != null && last.next != null; last = last.next) + { + ; + } + if (last == null || last == p) + { + last2 = null; + } + else + { + for (last2 = p; last2.next != last; last2 = last2.next) + { + ; + } + } + if (last instanceof Multi && i1.intValue() == 0 && + i2.intValue() == 1) + { + ( (Multi) last).matchFewest = true; + } + else if (last instanceof FastMulti && i1.intValue() == 0 && + i2.intValue() == 1) + { + ( (FastMulti) last).matchFewest = true; + } + else if (last instanceof DotMulti && i1.intValue() == 0 && + i2.intValue() == 1) + { + ( (DotMulti) last).matchFewest = true; + } + else if (last instanceof Multi + || last instanceof DotMulti + || last instanceof FastMulti) + { + throw new RegSyntax("Syntax error."); + } + else if (last2 == null) + { + p = mkMulti(i1, i2, p); + } + else + { + last2.next = mkMulti(i1, i2, last); + } + } + + final static Pattern mkMulti(patInt lo, patInt hi, Pattern p) + throws RegSyntax + { + if (p instanceof Any && p.next == null) + { + return (Pattern)new DotMulti(lo, hi); + } + return RegOpt.safe4fm(p) ? (Pattern)new FastMulti(lo, hi, p) : + (Pattern)new Multi(lo, hi, p); + } + + // process the bracket operator + Pattern matchBracket(StrPos sp) + throws RegSyntax + { + Bracket ret; + if (sp.match('^')) + { + ret = new Bracket(true); + sp.inc(); + } + else + { + ret = new Bracket(false); + } + if (sp.match(']')) + { + //throw new RegSyntax + RegSyntaxError.endItAll("Unmatched []"); + } + + while (!sp.eos && !sp.match(']')) + { + StrPos s1 = new StrPos(sp); + s1.inc(); + StrPos s1_ = new StrPos(s1); + s1_.inc(); + if (s1.match('-') && !s1_.match(']')) + { + StrPos s2 = new StrPos(s1); + s2.inc(); + if (!s2.eos) + { + ret.addOr(new Range(sp.c, s2.c)); + } + sp.inc(); + sp.inc(); + } + else if (sp.escMatch('Q')) + { + sp.inc(); + while (!sp.escMatch('E')) + { + ret.addOr(new oneChar(sp.c)); + sp.inc(); + } + } + else if (sp.escMatch('d')) + { + ret.addOr(new Range('0', '9')); + } + else if (sp.escMatch('s')) + { + ret.addOr(new oneChar( (char) 32)); + ret.addOr(new Range( (char) 8, (char) 10)); + ret.addOr(new oneChar( (char) 13)); + } + else if (sp.escMatch('w')) + { + ret.addOr(new Range('a', 'z')); + ret.addOr(new Range('A', 'Z')); + ret.addOr(new Range('0', '9')); + ret.addOr(new oneChar('_')); + } + else if (sp.escMatch('D')) + { + ret.addOr(new Range( (char) 0, (char) 47)); + ret.addOr(new Range( (char) 58, (char) 65535)); + } + else if (sp.escMatch('S')) + { + ret.addOr(new Range( (char) 0, (char) 7)); + ret.addOr(new Range( (char) 11, (char) 12)); + ret.addOr(new Range( (char) 14, (char) 31)); + ret.addOr(new Range( (char) 33, (char) 65535)); + } + else if (sp.escMatch('W')) + { + ret.addOr(new Range( (char) 0, (char) 64)); + ret.addOr(new Range( (char) 91, (char) 94)); + ret.addOr(new oneChar( (char) 96)); + ret.addOr(new Range( (char) 123, (char) 65535)); + } + else if (sp.escMatch('x') && next2Hex(sp)) + { + sp.inc(); + int d = getHexDigit(sp); + sp.inc(); + d = 16 * d + getHexDigit(sp); + ret.addOr(new oneChar( (char) d)); + } + else if (sp.escMatch('a')) + { + ret.addOr(new oneChar( (char) 7)); + } + else if (sp.escMatch('f')) + { + ret.addOr(new oneChar( (char) 12)); + } + else if (sp.escMatch('e')) + { + ret.addOr(new oneChar( (char) 27)); + } + else if (sp.escMatch('n')) + { + ret.addOr(new oneChar('\n')); + } + else if (sp.escMatch('t')) + { + ret.addOr(new oneChar('\t')); + } + else if (sp.escMatch('r')) + { + ret.addOr(new oneChar('\r')); + } + else if (sp.escMatch('c')) + { + sp.inc(); + if (sp.c < Ctrl.cmap.length) + { + ret.addOr(new oneChar(Ctrl.cmap[sp.c])); + } else - last2.next = mkMulti(i1,i2,last); - } - final static Pattern mkMulti(patInt lo,patInt hi,Pattern p) throws RegSyntax { - if(p instanceof Any && p.next == null) - return (Pattern)new DotMulti(lo,hi); - return RegOpt.safe4fm(p) ? (Pattern)new FastMulti(lo,hi,p) : - (Pattern)new Multi(lo,hi,p); - } - // process the bracket operator - Pattern matchBracket(StrPos sp) throws RegSyntax { - Bracket ret; - if(sp.match('^')) { - ret = new Bracket(true); - sp.inc(); - } else - ret = new Bracket(false); - if(sp.match(']')) - //throw new RegSyntax - RegSyntaxError.endItAll("Unmatched []"); - - while(!sp.eos && !sp.match(']')) { - StrPos s1 = new StrPos(sp); - s1.inc(); - StrPos s1_ = new StrPos(s1); - s1_.inc(); - if(s1.match('-') && !s1_.match(']')) { - StrPos s2 = new StrPos(s1); - s2.inc(); - if(!s2.eos) - ret.addOr(new Range(sp.c,s2.c)); - sp.inc(); - sp.inc(); - } else if(sp.escMatch('Q')) { - sp.inc(); - while(!sp.escMatch('E')) { - ret.addOr(new oneChar(sp.c)); - sp.inc(); - } - } else if(sp.escMatch('d')) { - ret.addOr(new Range('0','9')); - } else if(sp.escMatch('s')) { - ret.addOr(new oneChar((char)32)); - ret.addOr(new Range((char)8,(char)10)); - ret.addOr(new oneChar((char)13)); - } else if(sp.escMatch('w')) { - ret.addOr(new Range('a','z')); - ret.addOr(new Range('A','Z')); - ret.addOr(new Range('0','9')); - ret.addOr(new oneChar('_')); - } else if(sp.escMatch('D')) { - ret.addOr(new Range((char)0,(char)47)); - ret.addOr(new Range((char)58,(char)65535)); - } else if(sp.escMatch('S')) { - ret.addOr(new Range((char)0,(char)7)); - ret.addOr(new Range((char)11,(char)12)); - ret.addOr(new Range((char)14,(char)31)); - ret.addOr(new Range((char)33,(char)65535)); - } else if(sp.escMatch('W')) { - ret.addOr(new Range((char)0,(char)64)); - ret.addOr(new Range((char)91,(char)94)); - ret.addOr(new oneChar((char)96)); - ret.addOr(new Range((char)123,(char)65535)); - } else if(sp.escMatch('x') && next2Hex(sp)) { - sp.inc(); - int d = getHexDigit(sp); - sp.inc(); - d = 16*d + getHexDigit(sp); - ret.addOr(new oneChar((char)d)); - } else if(sp.escMatch('a')) { - ret.addOr(new oneChar((char)7)); - } else if(sp.escMatch('f')) { - ret.addOr(new oneChar((char)12)); - } else if(sp.escMatch('e')) { - ret.addOr(new oneChar((char)27)); - } else if(sp.escMatch('n')) { - ret.addOr(new oneChar('\n')); - } else if(sp.escMatch('t')) { - ret.addOr(new oneChar('\t')); - } else if(sp.escMatch('r')) { - ret.addOr(new oneChar('\r')); - } else if(sp.escMatch('c')) { - sp.inc(); - if(sp.c < Ctrl.cmap.length) - ret.addOr(new oneChar(Ctrl.cmap[sp.c])); - else - ret.addOr(new oneChar(sp.c)); - } else if(isOctalString(sp)) { - int d = sp.c - '0'; - sp.inc(); - d = 8*d + sp.c - '0'; - StrPos sp2 = new StrPos(sp); - sp2.inc(); - if(isOctalDigit(sp2,false)) { - sp.inc(); - d = 8*d + sp.c - '0'; - } - ret.addOr(new oneChar((char)d)); - } else - ret.addOr(new oneChar(sp.c)); - sp.inc(); + { + ret.addOr(new oneChar(sp.c)); + } + } + else if (isOctalString(sp)) + { + int d = sp.c - '0'; + sp.inc(); + d = 8 * d + sp.c - '0'; + StrPos sp2 = new StrPos(sp); + sp2.inc(); + if (isOctalDigit(sp2, false)) + { + sp.inc(); + d = 8 * d + sp.c - '0'; + } + ret.addOr(new oneChar( (char) d)); + } + else + { + ret.addOr(new oneChar(sp.c)); + } + sp.inc(); + } + return ret; + } + + /** Converts the stored Pattern to a String -- this is a + decompile. Note that \t and \n will really print out here, + Not just the two character representations. + Also be prepared to see some strange output if your characters + are not printable. */ + public String toString() + { + if (false && thePattern == null) + { + return ""; + } + else + { + StringBuffer sb = new StringBuffer(); + if (esc != Pattern.ESC) + { + sb.append("(?e="); + sb.append(esc); + sb.append(")"); + } + if (gFlag + || mFlag + || !dotDoesntMatchCR + || sFlag + || ignoreCase + || dontMatchInQuotes + || optimized()) + { + sb.append("(?"); + if (ignoreCase) + { + sb.append("i"); } - return ret; - } - - /** Converts the stored Pattern to a String -- this is a - decompile. Note that \t and \n will really print out here, - Not just the two character representations. - Also be prepared to see some strange output if your characters - are not printable. */ - public String toString() { - if( false && thePattern == null ) - return ""; - else { - StringBuffer sb = new StringBuffer(); - if(esc != Pattern.ESC) { - sb.append("(?e="); - sb.append(esc); - sb.append(")"); - } - if(gFlag - ||mFlag - ||!dotDoesntMatchCR - ||sFlag - ||ignoreCase - ||dontMatchInQuotes - ||optimized()) { - sb.append("(?"); - if(ignoreCase)sb.append("i"); - if(mFlag)sb.append("m"); - if(sFlag||!dotDoesntMatchCR)sb.append("s"); - if(dontMatchInQuotes)sb.append("Q"); - if(optimized())sb.append("o"); - if(gFlag)sb.append("g"); - sb.append(")"); - } - String patstr = thePattern.toString(); - if(esc != Pattern.ESC) - patstr = reEscape(patstr,Pattern.ESC,esc); - sb.append(patstr); - return sb.toString(); + if (mFlag) + { + sb.append("m"); } + if (sFlag || !dotDoesntMatchCR) + { + sb.append("s"); + } + if (dontMatchInQuotes) + { + sb.append("Q"); + } + if (optimized()) + { + sb.append("o"); + } + if (gFlag) + { + sb.append("g"); + } + sb.append(")"); + } + String patstr = thePattern.toString(); + if (esc != Pattern.ESC) + { + patstr = reEscape(patstr, Pattern.ESC, esc); + } + sb.append(patstr); + return sb.toString(); } - // Re-escape Pattern, allows us to use a different escape - // character. - static String reEscape(String s,char oldEsc,char newEsc) { - if(oldEsc == newEsc) return s; - int i; - StringBuffer sb = new StringBuffer(); - for(i=0;iThis method will attempt to rewrite - your pattern in a way that makes it faster (not all patterns - execute at the same speed). In general, "(?: ... )" will be - faster than "( ... )" so if you don't need the backreference, - you should group using the former pattern.

It will also - introduce new pattern elements that you can't get to otherwise, - for example if you have a large table of strings, i.e. the - months of the year "(January|February|...)" optimize() will make - a Hashtable that takes it to the next appropriate pattern - element -- eliminating the need for a linear search. - @see com.stevesoft.pat.Regex#optimized - @see com.stevesoft.pat.Regex#ignoreCase - @see com.stevesoft.pat.Regex#dontMatchInQuotes - @see com.stevesoft.pat.Regex#matchAt - @see com.stevesoft.pat.Regex#search - */ - public void optimize() { - if(optimized()||thePattern==null) return; - minMatch = new patInt(0);//thePattern.countMinChars(); - thePattern = RegOpt.opt(thePattern,ignoreCase, - dontMatchInQuotes); - skipper = Skip.findSkip(this); - //RegOpt.setParents(this); - return; - } - Skip skipper; - /** This function returns true if the optimize method has - been called. */ - public boolean optimized() { - return minMatch != null; - } - - /** A bit of syntactic surgar for those who want to make - their code look more perl-like. To use this initialize - your Regex object by saying: -

-        Regex r1 = Regex.perlCode("s/hello/goodbye/");
-        Regex r2 = Regex.perlCode("s'fish'frog'i");
-        Regex r3 = Regex.perlCode("m'hello');
-        
- The i for ignoreCase is supported in - this syntax, as well as m, s, and x. The g flat - is a bit of a special case.

- If you wish to replace all occurences of a pattern, you - do not put a 'g' in the perlCode, but call Regex's - replaceAll method.

- If you wish to simply - and only do a search for r2's pattern, you can do this - by calling the searchFrom method method repeatedly, or - by calling search repeatedly if the g flag is set. -

- Note: Currently perlCode does not - support the (?e=#) syntax for - changing the escape character. - */ - - public static Regex perlCode(String s) { - // this file is big enough, see parsePerl.java - // for this function. - return parsePerl.parse(s); - } - static final char back_slash = '\\'; - - /** Checks to see if there are only literal and no special - pattern elements in this Regex. */ - public boolean isLiteral() { - Pattern x = thePattern; - while(x != null) { - if(x instanceof oneChar) - ; - else if(x instanceof Skipped) - ; - else - return false; - x = x.next; + else + { + sb.append(newEsc); + sb.append(s.charAt(i + 1)); } - return true; + i++; + } + else if (s.charAt(i) == newEsc) + { + sb.append(newEsc); + sb.append(newEsc); + } + else + { + sb.append(s.charAt(i)); + } + } + return sb.toString(); + } + + /** This method implements FilenameFilter, allowing one + to use a Regex to search through a directory using File.list. + There is a FileRegex now that does this better. + @see com.stevesoft.pat.FileRegex + */ + public boolean accept(File dir, String s) + { + return search(s); + } + + /** The version of this package */ + final static public String version() + { + return "lgpl release 1.5.3"; + } + + /** Once this method is called, the state of variables + ignoreCase and dontMatchInQuotes should not be changed as the + results will be unpredictable. However, + search and matchAt will run more quickly. Note that you + can check to see if the pattern has been optimized by calling + the optimized() method.

This method will attempt to rewrite + your pattern in a way that makes it faster (not all patterns + execute at the same speed). In general, "(?: ... )" will be + faster than "( ... )" so if you don't need the backreference, + you should group using the former pattern.

It will also + introduce new pattern elements that you can't get to otherwise, + for example if you have a large table of strings, i.e. the + months of the year "(January|February|...)" optimize() will make + a Hashtable that takes it to the next appropriate pattern + element -- eliminating the need for a linear search. + @see com.stevesoft.pat.Regex#optimized + @see com.stevesoft.pat.Regex#ignoreCase + @see com.stevesoft.pat.Regex#dontMatchInQuotes + @see com.stevesoft.pat.Regex#matchAt + @see com.stevesoft.pat.Regex#search + */ + public void optimize() + { + if (optimized() || thePattern == null) + { + return; + } + minMatch = new patInt(0); //thePattern.countMinChars(); + thePattern = RegOpt.opt(thePattern, ignoreCase, + dontMatchInQuotes); + skipper = Skip.findSkip(this); + //RegOpt.setParents(this); + return; + } + + Skip skipper; + /** This function returns true if the optimize method has + been called. */ + public boolean optimized() + { + return minMatch != null; + } + + /** A bit of syntactic surgar for those who want to make + their code look more perl-like. To use this initialize + your Regex object by saying: +

+      Regex r1 = Regex.perlCode("s/hello/goodbye/");
+      Regex r2 = Regex.perlCode("s'fish'frog'i");
+      Regex r3 = Regex.perlCode("m'hello');
+      
+ The i for ignoreCase is supported in + this syntax, as well as m, s, and x. The g flat + is a bit of a special case.

+ If you wish to replace all occurences of a pattern, you + do not put a 'g' in the perlCode, but call Regex's + replaceAll method.

+ If you wish to simply + and only do a search for r2's pattern, you can do this + by calling the searchFrom method method repeatedly, or + by calling search repeatedly if the g flag is set. +

+ Note: Currently perlCode does not + support the (?e=#) syntax for + changing the escape character. + */ + + public static Regex perlCode(String s) + { + // this file is big enough, see parsePerl.java + // for this function. + return parsePerl.parse(s); + } + + static final char back_slash = '\\'; + + /** Checks to see if there are only literal and no special + pattern elements in this Regex. */ + public boolean isLiteral() + { + Pattern x = thePattern; + while (x != null) + { + if (x instanceof oneChar) + { + ; + } + else if (x instanceof Skipped) + { + ; + } + else + { + return false; + } + x = x.next; } + return true; + } - /** You only need to know about this if you are inventing - your own pattern elements. */ - public patInt countMinChars() { return thePattern.countMinChars(); } - /** You only need to know about this if you are inventing - your own pattern elements. */ - public patInt countMaxChars() { return thePattern.countMaxChars(); } + /** You only need to know about this if you are inventing + your own pattern elements. */ + public patInt countMinChars() + { + return thePattern.countMinChars(); + } + + /** You only need to know about this if you are inventing + your own pattern elements. */ + public patInt countMaxChars() + { + return thePattern.countMaxChars(); + } - boolean isHexDigit(StrPos sp) { - boolean r = + boolean isHexDigit(StrPos sp) + { + boolean r = !sp.eos && !sp.dontMatch - && ((sp.c>='0'&&sp.c<='9') - ||(sp.c>='a'&&sp.c<='f') - ||(sp.c>='A'&&sp.c<='F')); - return r; - } - boolean isOctalDigit(StrPos sp,boolean first) { - boolean r = - !sp.eos && !(first^sp.dontMatch) - && sp.c>='0'&&sp.c<='7'; - return r; - } - int getHexDigit(StrPos sp) { - if(sp.c >= '0' && sp.c <= '9') - return sp.c - '0'; - if(sp.c >= 'a' && sp.c <= 'f') - return sp.c - 'a' + 10; - return sp.c - 'A' + 10; - } - boolean next2Hex(StrPos sp) { - StrPos sp2 = new StrPos(sp); - sp2.inc(); - if(!isHexDigit(sp2)) - return false; - sp2.inc(); - if(!isHexDigit(sp2)) - return false; - return true; + && ( (sp.c >= '0' && sp.c <= '9') + || (sp.c >= 'a' && sp.c <= 'f') + || (sp.c >= 'A' && sp.c <= 'F')); + return r; + } + + boolean isOctalDigit(StrPos sp, boolean first) + { + boolean r = + !sp.eos && ! (first ^ sp.dontMatch) + && sp.c >= '0' && sp.c <= '7'; + return r; + } + + int getHexDigit(StrPos sp) + { + if (sp.c >= '0' && sp.c <= '9') + { + return sp.c - '0'; } - boolean isOctalString(StrPos sp) { - if(!isOctalDigit(sp,true)) - return false; - StrPos sp2 = new StrPos(sp); - sp2.inc(); - if(!isOctalDigit(sp2,false)) - return false; - return true; + if (sp.c >= 'a' && sp.c <= 'f') + { + return sp.c - 'a' + 10; } + return sp.c - 'A' + 10; + } + + boolean next2Hex(StrPos sp) + { + StrPos sp2 = new StrPos(sp); + sp2.inc(); + if (!isHexDigit(sp2)) + { + return false; + } + sp2.inc(); + if (!isHexDigit(sp2)) + { + return false; + } + return true; + } + + boolean isOctalString(StrPos sp) + { + if (!isOctalDigit(sp, true)) + { + return false; + } + StrPos sp2 = new StrPos(sp); + sp2.inc(); + if (!isOctalDigit(sp2, false)) + { + return false; + } + return true; + } } diff --git a/src/com/stevesoft/pat/RegexReader.java b/src/com/stevesoft/pat/RegexReader.java index 0ff33e3..6475dfe 100755 --- a/src/com/stevesoft/pat/RegexReader.java +++ b/src/com/stevesoft/pat/RegexReader.java @@ -8,6 +8,7 @@ package com.stevesoft.pat; import java.io.*; + import com.stevesoft.pat.wrap.*; /** This class allows you to replace the text in strings @@ -15,8 +16,10 @@ import com.stevesoft.pat.wrap.*; this freedom... using Regex.perlCode("s{.*}{x}s") as your pattern will result in loading the entire contents of the Reader into memory. - */ -public class RegexReader extends Reader { + */ +public class RegexReader + extends Reader +{ RBuffer rb = new RBuffer(new StringBuffer()); PartialBuffer wrap = new PartialBuffer(rb.sb); boolean moreToRead = true; @@ -24,185 +27,259 @@ public class RegexReader extends Reader { Replacer rp; // the buffer size - int nmax = 2*1024; + int nmax = 2 * 1024; - public RegexReader(Regex rex,Reader r) { + public RegexReader(Regex rex, Reader r) + { this.r = r; rp = rex.getReplacer(); } - public RegexReader(Transformer tex,Reader r) { + + public RegexReader(Transformer tex, Reader r) + { this.r = r; rp = tex.getReplacer(); } - public void reset() throws IOException { + + public void reset() + throws IOException + { r.reset(); rb = new RBuffer(new StringBuffer()); wrap = new PartialBuffer(rb.sb); moreToRead = true; } - void readData() throws IOException { + + void readData() + throws IOException + { int c; int n = 0; - while( (c = r.read()) != -1) { - rb.sb.append((char)c); - if(n++ > nmax) + while ( (c = r.read()) != -1) + { + rb.sb.append( (char) c); + if (n++ > nmax) + { break; + } } - if(c == -1 && n == 0) { + if (c == -1 && n == 0) + { moreToRead = false; wrap.allowOverRun = false; } } - void getMoreData() throws IOException { - while(rb.pos >= rb.epos) { + + void getMoreData() + throws IOException + { + while (rb.pos >= rb.epos) + { wrap.overRun = false; - if(rb.next != null) { - rb = rb.next; - } else if(rb.done) { + if (rb.next != null) + { + rb = rb.next; + } + else if (rb.done) + { break; - } else if(rb.epos >= rb.sb.length() - && rb.epos > nmax) { - rb.pos = 1; - rb.epos = 1; - rb.sb.setLength(1); - readData(); - } else if(rb.epos >= rb.sb.length() - && moreToRead) { + } + else if (rb.epos >= rb.sb.length() + && rb.epos > nmax) + { + rb.pos = 1; + rb.epos = 1; + rb.sb.setLength(1); + readData(); + } + else if (rb.epos >= rb.sb.length() + && moreToRead) + { readData(); - } else if(rp.getRegex().matchAt(wrap,rb.epos)) { - if(wrap.overRun) { - readData(); - } else { - StringBufferWrap sbw = new StringBufferWrap(); - StringBufferLike sbl = new StringBufferLike(sbw); - /* - ReplaceRule rr = rex.getReplaceRule(); - while(rr != null) { - rr.apply(sbl,rex); - rr = rr.next; - } - */ - Regex rex = rp.getRegex(); - int npos = rex.matchedTo(); - rp.setBuffer(sbl); - rp.setSource(wrap); - rp.setPos(npos); - rp.apply(rex,rex.getReplaceRule()); - int opos = rb.epos; - RBuffer rb2 = new RBuffer((StringBuffer)sbw.unwrap()); - rb2.epos = rb2.sb.length(); - RBuffer rb3 = new RBuffer(rb.sb); - - rb.next = rb2; - rb2.next = rb3; - - if(npos == opos) { - rb3.epos = npos+1; - if(rb3.epos > rb3.sb.length()) { - if(rb.pos >= rb.epos) - rb = rb.next; - rb3.pos = rb3.epos = 0; - rb3.done = true; - //break; - } + } + else if (rp.getRegex().matchAt(wrap, rb.epos)) + { + if (wrap.overRun) + { + readData(); + } + else + { + StringBufferWrap sbw = new StringBufferWrap(); + StringBufferLike sbl = new StringBufferLike(sbw); + /* + ReplaceRule rr = rex.getReplaceRule(); + while(rr != null) { + rr.apply(sbl,rex); + rr = rr.next; + } + */ + Regex rex = rp.getRegex(); + int npos = rex.matchedTo(); + rp.setBuffer(sbl); + rp.setSource(wrap); + rp.setPos(npos); + rp.apply(rex, rex.getReplaceRule()); + int opos = rb.epos; + RBuffer rb2 = new RBuffer( (StringBuffer) sbw.unwrap()); + rb2.epos = rb2.sb.length(); + RBuffer rb3 = new RBuffer(rb.sb); + + rb.next = rb2; + rb2.next = rb3; + + if (npos == opos) + { + rb3.epos = npos + 1; + if (rb3.epos > rb3.sb.length()) + { + if (rb.pos >= rb.epos) + { + rb = rb.next; + } + rb3.pos = rb3.epos = 0; + rb3.done = true; + //break; + } rb3.pos = npos; - } else { - rb3.pos = rb3.epos = npos; - } + } + else + { + rb3.pos = rb3.epos = npos; + } } - } else { - if(wrap.overRun) { - readData(); - } else if(rb.epos= rb.epos) { + + public int read() + throws IOException + { + if (rb.pos >= rb.epos) + { getMoreData(); - if(rb.pos >= rb.epos) + if (rb.pos >= rb.epos) + { return -1; + } } //System.out.println(rb); return rb.sb.charAt(rb.pos++); } - public int read(char[] buf,int off,int len) - throws IOException + + public int read(char[] buf, int off, int len) + throws IOException { int c = -1; - int end = off+len; - for(int i=off;iCopyright 2001, Steven R. Brandt -*/ /** -The RegexTokenizer is similar to the StringTokenizer class -provided with java, but allows one to tokenize using -regular expressions, rather than a simple list of characters. -Tokens are any strings between the supplied regular expression, -as well as any backreferences (things in parenthesis) -contained within the regular expression. */ -public class RegexTokenizer implements Enumeration { - String toParse; - Regex r; - int count = 0; - Vector v = new Vector(); - Vector vi = new Vector(); - int pos=0; + */ +/** + The RegexTokenizer is similar to the StringTokenizer class + provided with java, but allows one to tokenize using + regular expressions, rather than a simple list of characters. + Tokens are any strings between the supplied regular expression, + as well as any backreferences (things in parenthesis) + contained within the regular expression. */ +public class RegexTokenizer + implements Enumeration +{ + String toParse; + Regex r; + int count = 0; + Vector v = new Vector(); + Vector vi = new Vector(); + int pos = 0; - int offset = 1; - void getMore() { - String s = r.right(); - if(r.searchFrom(toParse,pos)) { - v.addElement(r.left().substring(pos)); - vi.addElement(new Integer(r.matchFrom()+ - r.charsMatched())); - for(int i=0;i= v.size()) getMore(); - return v.elementAt(count++); + else if (s != null) + { + v.addElement(s); } - /** This is the equivalent (String)nextElement(). */ - public String nextToken() { return (String)nextElement(); } - /** This asks for the next token, and changes the pattern - being used at the same time. */ - public String nextToken(String newpat) { - try { r.compile(newpat); } catch (RegSyntax r_) {} - return nextToken(r); + } + + /** Initialize the tokenizer with a string of text and a pattern */ + public RegexTokenizer(String txt, String ptrn) + { + toParse = txt; + r = new Regex(ptrn); + offset = Regex.BackRefOffset; + getMore(); + } + + /** Initialize the tokenizer with a Regex object. */ + public RegexTokenizer(String txt, Regex r) + { + toParse = txt; + this.r = r; + offset = Regex.BackRefOffset; + getMore(); + } + + /** This should always be cast to a String, as in StringTokenizer, + and as in StringTokenizer one can do this by calling + nextString(). */ + public Object nextElement() + { + if (count >= v.size()) + { + getMore(); } - /** This asks for the next token, and changes the pattern - being used at the same time. */ - public String nextToken(Regex nr) { - r = nr; - if(vi.size() > count) { - pos = ((Integer)vi.elementAt(count)).intValue(); - v.setSize(count); - vi.setSize(count); - } - getMore(); - return nextToken(); + return v.elementAt(count++); + } + + /** This is the equivalent (String)nextElement(). */ + public String nextToken() + { + return (String) nextElement(); + } + + /** This asks for the next token, and changes the pattern + being used at the same time. */ + public String nextToken(String newpat) + { + try + { + r.compile(newpat); } - /** Tells whether there are more tokens in the pattern. */ - public boolean hasMoreElements() { - if(count >= v.size()) getMore(); - return count < v.size(); + catch (RegSyntax r_) + {} + return nextToken(r); + } + + /** This asks for the next token, and changes the pattern + being used at the same time. */ + public String nextToken(Regex nr) + { + r = nr; + if (vi.size() > count) + { + pos = ( (Integer) vi.elementAt(count)).intValue(); + v.setSize(count); + vi.setSize(count); } - /** Tells whether there are more tokens in the pattern, but - in the fashion of StringTokenizer. */ - public boolean hasMoreTokens() { return hasMoreElements(); } - /** Determines the # of remaining tokens */ - public int countTokens() { - int _count=count; - while(hasMoreTokens()) - nextToken(); - count=_count; - return v.size()-count; + getMore(); + return nextToken(); + } + + /** Tells whether there are more tokens in the pattern. */ + public boolean hasMoreElements() + { + if (count >= v.size()) + { + getMore(); } - /** Returns all tokens in the String */ - public String[] allTokens() { - countTokens(); - String[] ret = new String[v.size()]; - v.copyInto(ret); - return ret; + return count < v.size(); + } + + /** Tells whether there are more tokens in the pattern, but + in the fashion of StringTokenizer. */ + public boolean hasMoreTokens() + { + return hasMoreElements(); + } + + /** Determines the # of remaining tokens */ + public int countTokens() + { + int _count = count; + while (hasMoreTokens()) + { + nextToken(); } + count = _count; + return v.size() - count; + } + + /** Returns all tokens in the String */ + public String[] allTokens() + { + countTokens(); + String[] ret = new String[v.size()]; + v.copyInto(ret); + return ret; + } }; diff --git a/src/com/stevesoft/pat/RegexWriter.java b/src/com/stevesoft/pat/RegexWriter.java index 008f6ac..bcfbd5b 100755 --- a/src/com/stevesoft/pat/RegexWriter.java +++ b/src/com/stevesoft/pat/RegexWriter.java @@ -8,6 +8,7 @@ package com.stevesoft.pat; import java.io.*; + import com.stevesoft.pat.wrap.*; /** A basic extension of FilterWriter that uses Transformer @@ -34,171 +35,232 @@ import com.stevesoft.pat.wrap.*; An illustration of this is given in the this example. */ -public class RegexWriter extends Writer { - Replacer repr; - Writer w; - WriterWrap ww; - StringBuffer sb = new StringBuffer(); - PartialBuffer wrap = new PartialBuffer(sb); - int pos, epos; - int interval = 128; - int bufferSize = 2*1024; - - public RegexWriter(Transformer t,Writer w) { - this.w = w; - ww = new WriterWrap(w); - repr = t.getReplacer(); - repr.setBuffer(new StringBufferLike(ww)); - repr.setSource(wrap); - } - public RegexWriter(Regex r,Writer w) { - this.w = w; - ww = new WriterWrap(w); - repr = r.getReplacer(); - repr.setBuffer(new StringBufferLike(ww)); - repr.setSource(wrap); - } +public class RegexWriter + extends Writer +{ + Replacer repr; + Writer w; + WriterWrap ww; + StringBuffer sb = new StringBuffer(); + PartialBuffer wrap = new PartialBuffer(sb); + int pos, epos; + int interval = 128; + int bufferSize = 2 * 1024; - char EOLchar = '\n'; - /** This method no longer serves any purpose. - @deprecated - */ - public char getEOLchar() { - return EOLchar; - } - /** This method no longer serves any purpose. - @deprecated - */ - public void setEOLchar(char c) { - EOLchar = c; - } + public RegexWriter(Transformer t, Writer w) + { + this.w = w; + ww = new WriterWrap(w); + repr = t.getReplacer(); + repr.setBuffer(new StringBufferLike(ww)); + repr.setSource(wrap); + } + + public RegexWriter(Regex r, Writer w) + { + this.w = w; + ww = new WriterWrap(w); + repr = r.getReplacer(); + repr.setBuffer(new StringBufferLike(ww)); + repr.setSource(wrap); + } + + char EOLchar = '\n'; + /** This method no longer serves any purpose. + @deprecated + */ + public char getEOLchar() + { + return EOLchar; + } - int max_lines=2; - /** This method no longer serves any purpose. - @deprecated - */ - public int getMaxLines() { return max_lines; } - /** This method no longer serves any purpose. - @deprecated - */ - public void setMaxLines(int ml) { max_lines = ml; } - - void write() throws IOException { - Regex rex = repr.getRegex(); - int eposOld = epos; - if(rex.matchAt(wrap,epos) && !wrap.overRun) { - while(pos < epos) - w.write(sb.charAt(pos++)); - int to = rex.matchedTo(); - repr.setPos(to); - repr.apply(rex,rex.getReplaceRule()); - epos = pos = to; - if(epos == eposOld && epos < sb.length()) - epos++; - } else if(!wrap.overRun && epos < sb.length()) { + /** This method no longer serves any purpose. + @deprecated + */ + public void setEOLchar(char c) + { + EOLchar = c; + } + + int max_lines = 2; + /** This method no longer serves any purpose. + @deprecated + */ + public int getMaxLines() + { + return max_lines; + } + + /** This method no longer serves any purpose. + @deprecated + */ + public void setMaxLines(int ml) + { + max_lines = ml; + } + + void write() + throws IOException + { + Regex rex = repr.getRegex(); + int eposOld = epos; + if (rex.matchAt(wrap, epos) && !wrap.overRun) + { + while (pos < epos) + { + w.write(sb.charAt(pos++)); + } + int to = rex.matchedTo(); + repr.setPos(to); + repr.apply(rex, rex.getReplaceRule()); + epos = pos = to; + if (epos == eposOld && epos < sb.length()) + { epos++; } - while(pos < epos) - w.write(sb.charAt(pos++)); - if(epos == sb.length()) { - sb.setLength(1); - pos = epos = 1; - } else if(pos > bufferSize) { - for(int i=bufferSize;i bufferSize) + { + for (int i = bufferSize; i < sb.length(); i++) + { + sb.setCharAt(i - bufferSize, sb.charAt(i)); } + pos -= bufferSize; + epos -= bufferSize; + sb.setLength(sb.length() - bufferSize); } + } - public void write(char[] ca,int b,int n) throws IOException { - int m = b+n; - for(int i=b;iThe argument to ReplaceRule.perlCode /. - */ - public static ReplaceRule perlCode(String s) { - //String sav_backGs = Regex.backGs; - //int sav_backGto = Regex.backGto; - try { - int mf = 0, mt = 0; - Regex gv = getv(); - ReplaceRule head = null; - Object tmp = null; - while(gv.searchFrom(s,mt)) { - int off=Regex.BackRefOffset-1; - mf = gv.matchedFrom(); - if(mf > mt) - head=add(head, - new StringRule(s.substring(mt,mf))); - String var = null; - if((var=gv.stringMatched(1+off)) != null - || (var=gv.stringMatched(2+off)) != null - || (var=gv.stringMatched(5+off)) != null) { - int d=0; - for(int i=0;i= 0) - head=add(head,new CodeRule(var.charAt(0)) ); - else - head=add(head,new StringRule(var) ); - } else if( - (var=gv.stringMatched(3+off)) != null - || (var=gv.stringMatched(4+off)) != null - || (var=gv.stringMatched(6+off)) != null) { - String arg = ""; - int pc; - if((pc=var.indexOf(':')) > 0) { - arg = var.substring(pc+1); - var = var.substring(0,pc); - } - if(var.equals("&")||var.equals("MATCH")) { - head=add(head,new AmpersandRule()); - } else if(var.equals("`")||var.equals("PREMATCH")) { - head=add(head,new LeftRule()); - } else if(var.equals("'")||var.equals("POSTMATCH")) { - head=add(head,new RightRule()); - } else if(var.equals("WANT_MORE_TEXT")) { - head=add(head,new WantMoreTextReplaceRule()); - } else if(var.equals("POP")) { - head=add(head,new PopRule()); - } else if(var.startsWith("+") && (tmp=defs.get(var.substring(1))) != null) { - if(tmp instanceof Regex) - head=add(head,new PushRule(var.substring(1),(Regex)tmp)); - else if(tmp instanceof Transformer) - head=add(head,new PushRule(var.substring(1),(Transformer)tmp)); - else head=add(head,new StringRule("${"+var+"}")); - } else if(var.startsWith("=") && (tmp=defs.get(var.substring(1))) != null) { - if(tmp instanceof Regex) - head=add(head,new ChangeRule(var.substring(1),(Regex)tmp)); - else if(tmp instanceof Transformer) - head=add(head,new ChangeRule(var.substring(1),(Transformer)tmp)); - else head=add(head,new StringRule("${"+var+"}")); - } else if( (tmp=defs.get(var)) != null) { - if(tmp instanceof ReplaceRule) { - ReplaceRule alt = ((ReplaceRule)tmp).arg(arg); - if(alt == null) alt = ((ReplaceRule)tmp); - head=add(head,(ReplaceRule)(alt.clone())); - } - } else // can't figure out how to transform this thing... - head=add(head,new StringRule("${"+var+"}")); - } else if( - (var = gv.stringMatched(7+off)) != null) { - char c = var.charAt(0); - if(c == 'n') - head=add(head,new StringRule("\n")); - else if(c == 't') - head=add(head,new StringRule("\t")); - else if(c == 'r') - head=add(head,new StringRule("\r")); - else if(c == 'b') - head=add(head,new StringRule("\r")); - else if(c == 'a') - head=add(head,new StringRule(""+(char)7)); - else if(c == 'e') - head=add(head,new StringRule(""+(char)27)); - else if(c == 'f') - head=add(head,new StringRule(""+(char)12)); - } else if( - (var = gv.stringMatched(8+off)) != null) { - char c = var.charAt(0); - if(c < Ctrl.cmap.length) - c = Ctrl.cmap[c]; - head=add(head,new StringRule(""+c)); - } else if( - (var = gv.stringMatched(9+off)) != null) { - int d = - 16*getHexDigit(var.charAt(0))+ - getHexDigit(var.charAt(1)); - head=add(head,new StringRule(""+(char)d)); - } - mt = gv.matchedTo(); + getvar = + new Regex( + "(?:\\\\(\\d+)|" + // ref 1 + "\\$(?:" + + "(\\d+)|" + // ref 2 + "(\\w+)|" + // ref 3 + "([&'`])|" + // ref 4 + "\\{(?:(\\d+)|" + // ref 5 + "([^\n}\\\\]+))}" + // ref 6 + ")|" + + "\\\\([nrbtaef])|" + // ref 7 + "\\\\c([\u0000-\uFFFF])|" + // ref 8 + "\\\\x([A-Fa-f0-9]{2})|" + // ref 9 + "\\\\([\u0000-\uFFFF])" + // ref 10 + ")"); + getvar.optimize(); + return getvar; + } + + /** Compile a ReplaceRule using the text that would go between + the second and third /'s in a typical substitution pattern + in Perl: s/ ... / The argument to ReplaceRule.perlCode /. + */ + public static ReplaceRule perlCode(String s) + { + //String sav_backGs = Regex.backGs; + //int sav_backGto = Regex.backGto; + try + { + int mf = 0, mt = 0; + Regex gv = getv(); + ReplaceRule head = null; + Object tmp = null; + while (gv.searchFrom(s, mt)) + { + int off = Regex.BackRefOffset - 1; + mf = gv.matchedFrom(); + if (mf > mt) + { + head = add(head, + new StringRule(s.substring(mt, mf))); + } + String var = null; + if ( (var = gv.stringMatched(1 + off)) != null + || (var = gv.stringMatched(2 + off)) != null + || (var = gv.stringMatched(5 + off)) != null) + { + int d = 0; + for (int i = 0; i < var.length(); i++) + { + d = 8 * d + (var.charAt(i) - '0'); + } + if (var.length() == 1) + { + head = add(head, new BackRefRule(d)); + } + else + { + head = new StringRule("" + (char) d); + } + } + else if ( + (var = gv.stringMatched(10 + off)) != null) + { + if ("QELlUu".indexOf(var) >= 0) + { + head = add(head, new CodeRule(var.charAt(0))); + } + else + { + head = add(head, new StringRule(var)); + } + } + else if ( + (var = gv.stringMatched(3 + off)) != null + || (var = gv.stringMatched(4 + off)) != null + || (var = gv.stringMatched(6 + off)) != null) + { + String arg = ""; + int pc; + if ( (pc = var.indexOf(':')) > 0) + { + arg = var.substring(pc + 1); + var = var.substring(0, pc); + } + if (var.equals("&") || var.equals("MATCH")) + { + head = add(head, new AmpersandRule()); + } + else if (var.equals("`") || var.equals("PREMATCH")) + { + head = add(head, new LeftRule()); + } + else if (var.equals("'") || var.equals("POSTMATCH")) + { + head = add(head, new RightRule()); + } + else if (var.equals("WANT_MORE_TEXT")) + { + head = add(head, new WantMoreTextReplaceRule()); + } + else if (var.equals("POP")) + { + head = add(head, new PopRule()); + } + else if (var.startsWith("+") && (tmp = defs.get(var.substring(1))) != null) + { + if (tmp instanceof Regex) + { + head = add(head, new PushRule(var.substring(1), (Regex) tmp)); + } + else if (tmp instanceof Transformer) + { + head = add(head, new PushRule(var.substring(1), (Transformer) tmp)); + } + else + { + head = add(head, new StringRule("${" + var + "}")); + } + } + else if (var.startsWith("=") && (tmp = defs.get(var.substring(1))) != null) + { + if (tmp instanceof Regex) + { + head = add(head, new ChangeRule(var.substring(1), (Regex) tmp)); + } + else if (tmp instanceof Transformer) + { + head = add(head, + new ChangeRule(var.substring(1), (Transformer) tmp)); } - if(mt <= s.length()) - head=add(head,new StringRule(s.substring(mt))); - return head; - } finally { - //Regex.backGs = sav_backGs; - //Regex.backGto = sav_backGto; + else + { + head = add(head, new StringRule("${" + var + "}")); + } + } + else if ( (tmp = defs.get(var)) != null) + { + if (tmp instanceof ReplaceRule) + { + ReplaceRule alt = ( (ReplaceRule) tmp).arg(arg); + if (alt == null) + { + alt = ( (ReplaceRule) tmp); + } + head = add(head, (ReplaceRule) (alt.clone())); + } + } + else // can't figure out how to transform this thing... + { + head = add(head, new StringRule("${" + var + "}")); + } + } + else if ( + (var = gv.stringMatched(7 + off)) != null) + { + char c = var.charAt(0); + if (c == 'n') + { + head = add(head, new StringRule("\n")); + } + else if (c == 't') + { + head = add(head, new StringRule("\t")); + } + else if (c == 'r') + { + head = add(head, new StringRule("\r")); + } + else if (c == 'b') + { + head = add(head, new StringRule("\r")); + } + else if (c == 'a') + { + head = add(head, new StringRule("" + (char) 7)); + } + else if (c == 'e') + { + head = add(head, new StringRule("" + (char) 27)); + } + else if (c == 'f') + { + head = add(head, new StringRule("" + (char) 12)); + } + } + else if ( + (var = gv.stringMatched(8 + off)) != null) + { + char c = var.charAt(0); + if (c < Ctrl.cmap.length) + { + c = Ctrl.cmap[c]; + } + head = add(head, new StringRule("" + c)); } + else if ( + (var = gv.stringMatched(9 + off)) != null) + { + int d = + 16 * getHexDigit(var.charAt(0)) + + getHexDigit(var.charAt(1)); + head = add(head, new StringRule("" + (char) d)); + } + mt = gv.matchedTo(); + } + if (mt <= s.length()) + { + head = add(head, new StringRule(s.substring(mt))); + } + return head; } - static Hashtable defs = new Hashtable(); - public static boolean isDefined(String s) { return defs.get(s) != null; } - public static void define(String s,Regex r) { defs.put(s,r); } - public static void define(String s,ReplaceRule r) { - defs.put(s,r); - r.name = s; + finally + { + //Regex.backGs = sav_backGs; + //Regex.backGto = sav_backGto; } - String name = getClass().getName(); - public static void define(String s,Transformer t) { defs.put(s,t); } - public static void undefine(String s) { defs.remove(s); } - /** This tells how to convert just the current element (and none - of the other items in the linked list) to a String. This - method is called by toString() for each item in the linked - list. */ - public String toString1() { - return "${"+name+"}"; + } + + static Hashtable defs = new Hashtable(); + public static boolean isDefined(String s) + { + return defs.get(s) != null; + } + + public static void define(String s, Regex r) + { + defs.put(s, r); + } + + public static void define(String s, ReplaceRule r) + { + defs.put(s, r); + r.name = s; + } + + String name = getClass().getName(); + + public static void define(String s, Transformer t) + { + defs.put(s, t); + } + + public static void undefine(String s) + { + defs.remove(s); + } + + /** This tells how to convert just the current element (and none + of the other items in the linked list) to a String. This + method is called by toString() for each item in the linked + list. */ + public String toString1() + { + return "${" + name + "}"; + } + + /** Convert to a String. */ + public final String toString() + { + StringBuffer sb = new StringBuffer(); + sb.append(toString1()); + ReplaceRule rr = this.next; + while (rr != null) + { + sb.append(rr.toString1()); + rr = rr.next; } - /** Convert to a String. */ - public final String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(toString1()); - ReplaceRule rr = this.next; - while(rr != null) { - sb.append(rr.toString1()); - rr = rr.next; - } - return sb.toString(); + return sb.toString(); + } + + /** Modified the behavior of a ReplaceRule by supplying + an argument. If a ReplaceRule named "foo" is defined + and the pattern "s/x/${foo:5}/" is given to Regex.perlCode, + then the "foo" the definition of "foo" will be retrieved + and arg("5") will be called. If the result is non-null, + that is the ReplaceRule that will be used. If the result + is null, then the pattern works just as if it were + "s/x/${foo}/". + @see com.stevesoft.pat.Validator#arg(java.lang.String) + */ + public ReplaceRule arg(String s) + { + return null; + } + + static int getHexDigit(char c) + { + if (c >= '0' && c <= '9') + { + return c - '0'; } - /** Modified the behavior of a ReplaceRule by supplying - an argument. If a ReplaceRule named "foo" is defined - and the pattern "s/x/${foo:5}/" is given to Regex.perlCode, - then the "foo" the definition of "foo" will be retrieved - and arg("5") will be called. If the result is non-null, - that is the ReplaceRule that will be used. If the result - is null, then the pattern works just as if it were - "s/x/${foo}/". - @see com.stevesoft.pat.Validator#arg(java.lang.String) - */ - public ReplaceRule arg(String s) { return null; } - static int getHexDigit(char c) { - if(c >= '0' && c <= '9') - return c - '0'; - if(c >= 'a' && c <= 'f') - return c - 'a'+10; - return c - 'A'+10; + if (c >= 'a' && c <= 'f') + { + return c - 'a' + 10; } + return c - 'A' + 10; + } } diff --git a/src/com/stevesoft/pat/Replacer.java b/src/com/stevesoft/pat/Replacer.java index bdeea39..77570f9 100755 --- a/src/com/stevesoft/pat/Replacer.java +++ b/src/com/stevesoft/pat/Replacer.java @@ -7,27 +7,32 @@ // package com.stevesoft.pat; -import com.stevesoft.pat.wrap.StringWrap; +import com.stevesoft.pat.wrap.*; /** Internally used class. */ -class RegHolder { - Regex me = null; - RegHolder prev = null; +class RegHolder +{ + Regex me = null; + RegHolder prev = null; } /** Internally used class. - * @see CodeRule - */ -class CodeVal { - int pos; - char code; - CodeVal(int p,char c) { - pos = p; - code = c; - } - public String toString() { - return "("+pos+","+code+")"; - } + * @see CodeRule + */ +class CodeVal +{ + int pos; + char code; + CodeVal(int p, char c) + { + pos = p; + code = c; + } + + public String toString() + { + return "(" + pos + "," + code + ")"; + } } /** @@ -43,217 +48,310 @@ class CodeVal { trans3.java. @see com.stevesoft.pat.Transformer @see com.stevesoft.pat.Regex -*/ -public class Replacer { - boolean first; + */ +public class Replacer +{ + boolean first; - /** Instantiate a new Replacer. */ - public Replacer() {} + /** Instantiate a new Replacer. */ + public Replacer() + {} - public StringLike replaceFirstRegion(String s,Regex r, - int start,int end) { - return replaceFirstRegion(new StringWrap(s),r,start,end); - } - /** This method replaces the first occurence of the Regex in the - String starting with position pos - according to the Replacer rule of this object. */ - public StringLike replaceFirstRegion(StringLike s,Regex r, - int start,int end) { - first = true; - rh.me = r; - rh.prev = null; - return dorep(s,start,end); - } - public StringLike replaceFirst(StringLike s) { - return replaceFirstRegion(s,0,s.length()); - } - public StringLike replaceFirstFrom(StringLike s,int start) { - return replaceFirstRegion(s,start,s.length()); - } - public StringLike replaceFirstRegion(StringLike s,int start,int end) { - first = true; - return dorep(s,start,end); - } + public StringLike replaceFirstRegion(String s, Regex r, + int start, int end) + { + return replaceFirstRegion(new StringWrap(s), r, start, end); + } - RegHolder rh = new RegHolder(); + /** This method replaces the first occurence of the Regex in the + String starting with position pos + according to the Replacer rule of this object. */ + public StringLike replaceFirstRegion(StringLike s, Regex r, + int start, int end) + { + first = true; + rh.me = r; + rh.prev = null; + return dorep(s, start, end); + } - public StringLike replaceAllRegion(String s,Regex r, - int start, int end) { - return replaceAllRegion(new StringWrap(s),r,start,end); - } - /** This method replaces all occurences of the Regex in the - String starting with postition pos - according to the Replacer rule of this object. */ - public StringLike replaceAllRegion(StringLike s,Regex r, - int start,int end) { - first = false; - // reset - rh.me = r; - rh.prev = null; - return dorep(s,start,end); - } - public StringLike replaceAll(StringLike s) { - return replaceAllRegion(s,0,s.length()); - } - public StringLike replaceAllFrom(StringLike s,int start) { - return replaceAllRegion(s,start,s.length()); - } - public StringLike replaceAllRegion(StringLike s,int start,int end) { - first = false; - return dorep(s,start,end); - } + public StringLike replaceFirst(StringLike s) + { + return replaceFirstRegion(s, 0, s.length()); + } - public String replaceAll(String s) { - return replaceAllRegion(new StringWrap(s),0,s.length()).toString(); - } - public String replaceAllFrom(String s,int start) { - return replaceAllRegion(new StringWrap(s),start,s.length()).toString(); - } - public String replaceAllRegion(String s,int start,int end) { - first = false; - return dorep(new StringWrap(s),start,end).toString(); - } + public StringLike replaceFirstFrom(StringLike s, int start) + { + return replaceFirstRegion(s, start, s.length()); + } - final public boolean isSpecial(ReplaceRule x) { - while(x != null) { - if(x instanceof SpecialRule - || (x instanceof RuleHolder && ((RuleHolder)x).held instanceof SpecialRule)) - return true; - x = x.next; - } - return false; - } - final public void apply1(RegRes rr) { - rr.charsMatched_++; - apply(rr,null); - rr.charsMatched_--; + public StringLike replaceFirstRegion(StringLike s, int start, int end) + { + first = true; + return dorep(s, start, end); + } + + RegHolder rh = new RegHolder(); + + public StringLike replaceAllRegion(String s, Regex r, + int start, int end) + { + return replaceAllRegion(new StringWrap(s), r, start, end); + } + + /** This method replaces all occurences of the Regex in the + String starting with postition pos + according to the Replacer rule of this object. */ + public StringLike replaceAllRegion(StringLike s, Regex r, + int start, int end) + { + first = false; + // reset + rh.me = r; + rh.prev = null; + return dorep(s, start, end); + } + + public StringLike replaceAll(StringLike s) + { + return replaceAllRegion(s, 0, s.length()); + } + + public StringLike replaceAllFrom(StringLike s, int start) + { + return replaceAllRegion(s, start, s.length()); + } + + public StringLike replaceAllRegion(StringLike s, int start, int end) + { + first = false; + return dorep(s, start, end); + } + + public String replaceAll(String s) + { + return replaceAllRegion(new StringWrap(s), 0, s.length()).toString(); + } + + public String replaceAllFrom(String s, int start) + { + return replaceAllRegion(new StringWrap(s), start, s.length()).toString(); + } + + public String replaceAllRegion(String s, int start, int end) + { + first = false; + return dorep(new StringWrap(s), start, end).toString(); + } + + final public boolean isSpecial(ReplaceRule x) + { + while (x != null) + { + if (x instanceof SpecialRule + || + (x instanceof RuleHolder && ( (RuleHolder) x).held instanceof SpecialRule)) + { + return true; + } + x = x.next; } + return false; + } + + final public void apply1(RegRes rr) + { + rr.charsMatched_++; + apply(rr, null); + rr.charsMatched_--; + } - final StringLike dorep(StringLike s,int start,int end) { - StringLike ret = s; - want_more_text = false; - lastMatchedTo = 0; - if(rh.me == null) - throw new NullPointerException("Replacer has null Regex pointer"); - if(rh.me._search(s,start,end)) { - int rmn = rh.me.matchedTo(); - if(rh.me.charsMatched()==0 && !isSpecial(rh.me.getReplaceRule())) { - apply1(rh.me); - rmn++; + final StringLike dorep(StringLike s, int start, int end) + { + StringLike ret = s; + want_more_text = false; + lastMatchedTo = 0; + if (rh.me == null) + { + throw new NullPointerException("Replacer has null Regex pointer"); + } + if (rh.me._search(s, start, end)) + { + int rmn = rh.me.matchedTo(); + if (rh.me.charsMatched() == 0 && !isSpecial(rh.me.getReplaceRule())) + { + apply1(rh.me); + rmn++; + } + apply(rh.me); + if (!first) + { + for (int i = rmn; + !want_more_text && rh.me._search(s, i, end); i = rmn) + { + rmn = rh.me.matchedTo(); + if (rh.me.charsMatched() == 0) + { + if (!isSpecial(rh.me.getReplaceRule())) + { + apply1(rh.me); } - apply(rh.me); - if(!first) - for(int i=rmn; - !want_more_text && rh.me._search(s,i,end);i=rmn) { - rmn = rh.me.matchedTo(); - if(rh.me.charsMatched()==0) { - if(!isSpecial(rh.me.getReplaceRule())) - apply1(rh.me); - rmn++; - } - apply(rh.me); - } - ret = finish(); - ret = ret == null ? s : ret; + rmn++; + } + apply(rh.me); } - return ret; + } + ret = finish(); + ret = ret == null ? s : ret; + } + return ret; + } + + StringBufferLike sb = null; + StringLike src = null; + int pos = 0; + /** This method allows you to apply the results of several + matches in a sequence to modify a String of text. Each + call in the sequence must operate on the same piece of + text and the matchedFrom() of each RegRes given to this + method must be greater in value than the preceeding + RegRes's matchedTo() value. + */ + public void apply(RegRes r, ReplaceRule rp) + { + if (rp == null || (rp.next == null && rp instanceof AmpersandRule)) + { + return; } + if (r.didMatch()) + { + if (src == null) + { + src = r.getStringLike(); + } + if (sb == null) + { + sb = new StringBufferLike(src.newStringBufferLike()); + } + int rmf = r.matchedFrom(); + for (int ii = pos; ii < rmf; ii++) + { + sb.append(src.charAt(ii)); + } - StringBufferLike sb = null; - StringLike src = null; - int pos = 0; - /** This method allows you to apply the results of several - matches in a sequence to modify a String of text. Each - call in the sequence must operate on the same piece of - text and the matchedFrom() of each RegRes given to this - method must be greater in value than the preceeding - RegRes's matchedTo() value. - */ - public void apply(RegRes r,ReplaceRule rp) { - if(rp==null ||(rp.next == null && rp instanceof AmpersandRule)) - return; - if(r.didMatch()) { - if(src == null) - src = r.getStringLike(); - if(sb == null) - sb = new StringBufferLike(src.newStringBufferLike()); - int rmf = r.matchedFrom(); - for(int ii=pos;iiCopyright 2001, Steven R. Brandt -*/ /** -This class only exists to store data needed during the -compilation of a regular expression. */ -public class Rthings { - /** The numeric identity of the next () to be encountered - while compiling the pattern. */ - public int val=Regex.BackRefOffset; - /** Needed in case (?i) is encountered, to pass back the - message that ignoreCase should be set. */ - public boolean ignoreCase; - /** Needed in case (?Q) is encountered, to pass back the - message that dontMatchInQuotes should be set. */ - public boolean dontMatchInQuotes; - public boolean optimizeMe = false; - public boolean noBackRefs = false; - public int parenLevel = 0; - boolean gFlag = false, mFlag = false, sFlag = false; - Pattern p; - Or o; - Rthings(Regex r) { - ignoreCase = r.ignoreCase; - dontMatchInQuotes = r.dontMatchInQuotes; - } - void set(Regex r) { - r.gFlag = gFlag; - r.mFlag = mFlag; - r.sFlag = sFlag; - r.ignoreCase = ignoreCase; - r.dontMatchInQuotes = dontMatchInQuotes; - if(optimizeMe) r.optimize(); + */ +/** + This class only exists to store data needed during the + compilation of a regular expression. */ +public class Rthings +{ + /** The numeric identity of the next () to be encountered + while compiling the pattern. */ + public int val = Regex.BackRefOffset; + /** Needed in case (?i) is encountered, to pass back the + message that ignoreCase should be set. */ + public boolean ignoreCase; + /** Needed in case (?Q) is encountered, to pass back the + message that dontMatchInQuotes should be set. */ + public boolean dontMatchInQuotes; + public boolean optimizeMe = false; + public boolean noBackRefs = false; + public int parenLevel = 0; + boolean gFlag = false, mFlag = false, sFlag = false; + Pattern p; + Or o; + Rthings(Regex r) + { + ignoreCase = r.ignoreCase; + dontMatchInQuotes = r.dontMatchInQuotes; + } + + void set(Regex r) + { + r.gFlag = gFlag; + r.mFlag = mFlag; + r.sFlag = sFlag; + r.ignoreCase = ignoreCase; + r.dontMatchInQuotes = dontMatchInQuotes; + if (optimizeMe) + { + r.optimize(); } + } }; diff --git a/src/com/stevesoft/pat/RuleHolder.java b/src/com/stevesoft/pat/RuleHolder.java index e732d58..9b8017d 100755 --- a/src/com/stevesoft/pat/RuleHolder.java +++ b/src/com/stevesoft/pat/RuleHolder.java @@ -6,15 +6,37 @@ // -- Happy Computing! // package com.stevesoft.pat; + /** This class is used internally. */ -class RuleHolder extends ReplaceRule { - ReplaceRule held = null; - RuleHolder() {} - RuleHolder(ReplaceRule h) { held = h; } - public Object clone1() { return new RuleHolder(held); } - public String toString1() { return held.toString1(); } - public void apply(StringBufferLike sb,RegRes rr) { - held.apply(sb,rr); - } - public ReplaceRule arg(String s) { return new RuleHolder(held.arg(s)); } +class RuleHolder + extends ReplaceRule +{ + ReplaceRule held = null; + RuleHolder() + {} + + RuleHolder(ReplaceRule h) + { + held = h; + } + + public Object clone1() + { + return new RuleHolder(held); + } + + public String toString1() + { + return held.toString1(); + } + + public void apply(StringBufferLike sb, RegRes rr) + { + held.apply(sb, rr); + } + + public ReplaceRule arg(String s) + { + return new RuleHolder(held.arg(s)); + } } diff --git a/src/com/stevesoft/pat/Skip.java b/src/com/stevesoft/pat/Skip.java index ca2dbb5..16aada1 100755 --- a/src/com/stevesoft/pat/Skip.java +++ b/src/com/stevesoft/pat/Skip.java @@ -13,113 +13,174 @@ package com.stevesoft.pat; version of String.indexOf. @see com.stevesoft.pat.Skip2 @see com.stevesoft.pat.SkipBMH - */ -public class Skip { - static int mkmask(int c) { - char x = (char)c; - return ~( CaseMgr.toUpperCase(x) | - CaseMgr.toLowerCase(x) | - CaseMgr.toTitleCase(x)); - } - String src; - int c,mask; - int offset; - boolean ign,m1; - /** Examine a Regex to determine what String it will - attempt to skip to when searching for patterns. - Return -1 if we aren't doing this. */ - public static String string(Regex r) { - return r.skipper == null ? null : r.skipper.src; - } - /** Determine the offset of the String within the pattern - that we are skipping to. Return -1 if we aren't doing - this. */ - public static int offset(Regex r) { - return r.skipper == null ? -1 : r.skipper.offset; + */ +public class Skip +{ + static int mkmask(int c) + { + char x = (char) c; + return~ (CaseMgr.toUpperCase(x) | + CaseMgr.toLowerCase(x) | + CaseMgr.toTitleCase(x)); + } + + String src; + int c, mask; + int offset; + boolean ign, m1; + /** Examine a Regex to determine what String it will + attempt to skip to when searching for patterns. + Return -1 if we aren't doing this. */ + public static String string(Regex r) + { + return r.skipper == null ? null : r.skipper.src; + } + + /** Determine the offset of the String within the pattern + that we are skipping to. Return -1 if we aren't doing + this. */ + public static int offset(Regex r) + { + return r.skipper == null ? -1 : r.skipper.offset; + } + + /** Initialize, give it a String to search for, tell it + whether or not to ignoreCase, and what the offset is + of the String within the String to be searched. */ + public Skip(String s, boolean ign, int o) + { + src = s; + c = s.charAt(0); + if (ign) + { + mask = mkmask(c); } - /** Initialize, give it a String to search for, tell it - whether or not to ignoreCase, and what the offset is - of the String within the String to be searched. */ - public Skip(String s,boolean ign,int o) { - src = s; - c = s.charAt(0); - if(ign) { - mask = mkmask(c); - } else mask = 0; - offset = o; - this.ign = ign; - m1 = (s.length()==1); + else + { + mask = 0; } - /** The same as find(s,0,s.length()) */ - public final int find(StringLike s) { - return find(s,0,s.length()); + offset = o; + this.ign = ign; + m1 = (s.length() == 1); + } + + /** The same as find(s,0,s.length()) */ + public final int find(StringLike s) + { + return find(s, 0, s.length()); + } + + static final int min(int a, int b) + { + return a < b ? a : b; + } + + /** Searches a given region of text beginning at position start + and ending at position end for the skip object. */ + public int find(StringLike s, int start, int end) + { + if (start > end) + { + return -1; } - static final int min(int a,int b) { return a end) return -1; - start += offset; - int vend = min(s.length()-1,end+offset); - if(mask != c) { - for(int i=start;i<=vend;i++) - if(0 == (s.charAt(i) & mask)) - //if(m1||s.regionMatches(ign,i,src,0,src.length()) ) - if(m1||CaseMgr.regionMatches(s,ign,i,src,0,src.length()) ) - return i-offset; - } else { - for(int i=start;i<=vend;i++) - if(c == s.charAt(i)) - //if(m1||s.regionMatches(ign,i,src,0,src.length()) ) - if(m1||CaseMgr.regionMatches(s,ign,i,src,0,src.length()) ) - return i-offset; + start += offset; + int vend = min(s.length() - 1, end + offset); + if (mask != c) + { + for (int i = start; i <= vend; i++) + { + if (0 == (s.charAt(i) & mask)) + { + //if(m1||s.regionMatches(ign,i,src,0,src.length()) ) + if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) + { + return i - offset; + } } - return -1; + } } - static Skip findSkip(Regex r) { - return findSkip(r.thePattern,r.ignoreCase,!r.dontMatchInQuotes); + else + { + for (int i = start; i <= vend; i++) + { + if (c == s.charAt(i)) + { + //if(m1||s.regionMatches(ign,i,src,0,src.length()) ) + if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) + { + return i - offset; + } + } + } } - // look for things that can be skipped - static Skip findSkip(Pattern p,boolean ignoreCase,boolean trnc) { - StringBuffer sb = new StringBuffer(); - Skip subsk = null; - int offset = 0; - int skipc = -1,skipoff=0; - for(;p != null;p = p.next) { - if(p instanceof oneChar) { - skipc = ((oneChar)p).c; - skipoff = offset; - } - if(p instanceof oneChar && p.next instanceof oneChar) { - Pattern psav = p; - sb.append(((oneChar)p).c); - while(p.next instanceof oneChar) { - sb.append(((oneChar)p.next).c); - p = p.next; - } - String st = sb.toString(); - Skip sk=null; - if(st.length()>2) - sk = new SkipBMH(st,ignoreCase,offset); - else - sk = new Skip2(st,ignoreCase,offset); - if(trnc && st.length()>2) { // chop out a whole string... - psav.next = new Skipped(st.substring(1)); - psav.next.next = p.next; - psav.next.parent = p.parent; - } - return sk; - } else if(p instanceof Or && ((Or)p).v.size()==1 - && !((Or)p).leftForm().equals("(?!") - && null != (subsk= - findSkip( (Pattern)((Or)p).v.elementAt(0),ignoreCase,trnc) )) { - subsk.offset += offset; - return subsk; - } else if(p.minChars().equals(p.maxChars())) { - offset += p.minChars().intValue(); - } else return skipc < 0 ? null : - new Skip(""+(char)skipc,ignoreCase,skipoff); + return -1; + } + + static Skip findSkip(Regex r) + { + return findSkip(r.thePattern, r.ignoreCase, !r.dontMatchInQuotes); + } + + // look for things that can be skipped + static Skip findSkip(Pattern p, boolean ignoreCase, boolean trnc) + { + StringBuffer sb = new StringBuffer(); + Skip subsk = null; + int offset = 0; + int skipc = -1, skipoff = 0; + for (; p != null; p = p.next) + { + if (p instanceof oneChar) + { + skipc = ( (oneChar) p).c; + skipoff = offset; + } + if (p instanceof oneChar && p.next instanceof oneChar) + { + Pattern psav = p; + sb.append( ( (oneChar) p).c); + while (p.next instanceof oneChar) + { + sb.append( ( (oneChar) p.next).c); + p = p.next; + } + String st = sb.toString(); + Skip sk = null; + if (st.length() > 2) + { + sk = new SkipBMH(st, ignoreCase, offset); + } + else + { + sk = new Skip2(st, ignoreCase, offset); + } + if (trnc && st.length() > 2) + { // chop out a whole string... + psav.next = new Skipped(st.substring(1)); + psav.next.next = p.next; + psav.next.parent = p.parent; } - return null; + return sk; + } + else if (p instanceof Or && ( (Or) p).v.size() == 1 + && ! ( (Or) p).leftForm().equals("(?!") + && null != (subsk = + findSkip( (Pattern) ( (Or) p).v.elementAt(0), + ignoreCase, trnc))) + { + subsk.offset += offset; + return subsk; + } + else if (p.minChars().equals(p.maxChars())) + { + offset += p.minChars().intValue(); + } + else + { + return skipc < 0 ? null : + new Skip("" + (char) skipc, ignoreCase, skipoff); + } } + return null; + } } diff --git a/src/com/stevesoft/pat/Skip2.java b/src/com/stevesoft/pat/Skip2.java index f2b03ca..ca1c5a8 100755 --- a/src/com/stevesoft/pat/Skip2.java +++ b/src/com/stevesoft/pat/Skip2.java @@ -11,28 +11,45 @@ package com.stevesoft.pat; of two characters in the initializing String. @see com.stevesoft.pat.Skip @see com.stevesoft.pat.SkipBMH - */ -public class Skip2 extends Skip { - int c1,mask1; - public Skip2(String s,boolean ign,int offset) { - super(s,ign,offset); - c1 = s.charAt(1); - m1 = 2==s.length(); - if(ign) { - mask1=mkmask(c1); - } else - mask1 = 0; + */ +public class Skip2 + extends Skip +{ + int c1, mask1; + public Skip2(String s, boolean ign, int offset) + { + super(s, ign, offset); + c1 = s.charAt(1); + m1 = 2 == s.length(); + if (ign) + { + mask1 = mkmask(c1); } - public int find(StringLike s,int start,int end) { - if(start > end) return -1; - start += offset; - int vend = min(s.length()-2,end+offset); - for(int i=start;i<=vend;i++) - if(0 == (s.charAt(i)&mask) && 0 == (s.charAt(i+1)&mask1)) { - //if(m1||s.regionMatches(ign,i,src,0,src.length()) ) - if(m1||CaseMgr.regionMatches(s,ign,i,src,0,src.length()) ) - return i-offset; - } - return -1; + else + { + mask1 = 0; } + } + + public int find(StringLike s, int start, int end) + { + if (start > end) + { + return -1; + } + start += offset; + int vend = min(s.length() - 2, end + offset); + for (int i = start; i <= vend; i++) + { + if (0 == (s.charAt(i) & mask) && 0 == (s.charAt(i + 1) & mask1)) + { + //if(m1||s.regionMatches(ign,i,src,0,src.length()) ) + if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) + { + return i - offset; + } + } + } + return -1; + } } diff --git a/src/com/stevesoft/pat/SkipBMH.java b/src/com/stevesoft/pat/SkipBMH.java index 4fbe381..632418e 100755 --- a/src/com/stevesoft/pat/SkipBMH.java +++ b/src/com/stevesoft/pat/SkipBMH.java @@ -7,10 +7,10 @@ // package com.stevesoft.pat; -import com.stevesoft.pat.wrap.StringWrap; +import com.stevesoft.pat.wrap.*; /** Like Skip, but implements a - + Boyer-Moore-Horspool type search method that has been modified to be more like a "T-search" (see the Michael Tamm''s article in C'T, magazin fuer computer und technic, August 97 @@ -20,164 +20,252 @@ import com.stevesoft.pat.wrap.StringWrap; beat String's indexOf method in many cases. @see com.stevesoft.pat.Skip @see com.stevesoft.pat.Skip2 - */ -public class SkipBMH extends Skip { - // This number could be 256, but I think it's - // big enough. Note, it must be a power of 2. - final int MAX_CHAR = 64; - final char[] skip = new char[MAX_CHAR]; - int sm1; - int jump_ahead = 0; - char uc,lc,tc,x; - final boolean exact(char c) { - return (ign && anyc(c))||c==x; + */ +public class SkipBMH + extends Skip +{ + // This number could be 256, but I think it's + // big enough. Note, it must be a power of 2. + final int MAX_CHAR = 64; + final char[] skip = new char[MAX_CHAR]; + int sm1; + int jump_ahead = 0; + char uc, lc, tc, x; + final boolean exact(char c) + { + return (ign && anyc(c)) || c == x; + } + + final boolean anyc(char c) + { + return c == uc || c == lc || c == tc; + } + + public SkipBMH(String pt, boolean ign) + { + this(pt, ign, 0); + } + + public SkipBMH(String pt) + { + this(pt, false, 0); + } + + public SkipBMH(String pt, boolean ign, int offset) + { + super(pt, ign, offset); + for (int k = 0; k < MAX_CHAR; k++) + { + skip[k] = (char) src.length(); } - final boolean anyc(char c) { - return c==uc||c==lc||c==tc; + + sm1 = src.length() - 1; + x = src.charAt(sm1); + uc = CaseMgr.toUpperCase(x); + lc = CaseMgr.toLowerCase(x); + tc = CaseMgr.toTitleCase(x); + + // We don't really want 65536 long arrays in skip[], + // so we mask of the higher bits. This can be combined + // with ignore case, so accounting for upper + // case costs us nothing extra. + for (int k = 0; k < src.length() - 1; k++) + { + char x_ = src.charAt(k); + if (ign) + { + char uc_ = CaseMgr.toUpperCase(x_); + char lc_ = CaseMgr.toLowerCase(x_); + char tc_ = CaseMgr.toTitleCase(x_); + skip[uc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); + skip[lc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); + skip[tc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); + } + else + { + skip[x_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); + } } - public SkipBMH(String pt,boolean ign) { this(pt,ign,0); } - public SkipBMH(String pt) { this(pt,false,0); } - public SkipBMH(String pt,boolean ign,int offset) { - super(pt,ign,offset); - for(int k=0;k vend) + { + return -1; + } } + } } - /** Set to true if you only want to compare two of the - characters in the String. */ - final public int searchRegion(String s,int start,int end) { - return find(s,start,end); + else + { + for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (x == s.charAt(k)) + { + //if(src.regionMatches(0,s,k-sm1,sm1)) + if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + } + } + for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (x == s.charAt(k)) + { + //if(src.regionMatches(0,s,k-sm1,sm1)) + if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + if (k > vend) + { + return -1; + } + } + } } - final public int searchFrom(String s,int start) { - return find(s,start,s.length()); + + return -1; + } + + public int find(StringLike s, int start, int end) + { + if (s instanceof StringWrap) + { + return find(s.toString(), start, end); } - final public int search(String s) { return find(s,0,s.length()); } - public int find(String s,int start,int end) { - start += offset+sm1; - int vend = min(s.length()-1,end+sm1+offset),k; - int vend1 = vend-jump_ahead; - if(ign) { - for(k=start; k <= vend1;k += skip[s.charAt(k) & (MAX_CHAR-1)] ) { - // table look-up is expensive, avoid it if possible - if( anyc(s.charAt(k)) ) { - if(CaseMgr.regionMatches(src,ign,0,s,k-sm1,sm1)) - return k-sm1-offset; - k += jump_ahead; - } - } - for(; k <= vend;k += skip[s.charAt(k) & (MAX_CHAR-1)] ) { - // table look-up is expensive, avoid it if possible - if( anyc(s.charAt(k)) ) { - if(CaseMgr.regionMatches(src,ign,0,s,k-sm1,sm1)) - return k-sm1-offset; - k += jump_ahead; - if(k > vend) return -1; - } - } - } else { - for(k=start; k <= vend1;k += skip[s.charAt(k) & (MAX_CHAR-1)] ) { - // table look-up is expensive, avoid it if possible - if( x==s.charAt(k) ) { - //if(src.regionMatches(0,s,k-sm1,sm1)) - if(CaseMgr.regionMatches(src,false,0,s,k-sm1,sm1)) - return k-sm1-offset; - k += jump_ahead; - } - } - for(; k <= vend;k += skip[s.charAt(k) & (MAX_CHAR-1)] ) { - // table look-up is expensive, avoid it if possible - if( x==s.charAt(k) ) { - //if(src.regionMatches(0,s,k-sm1,sm1)) - if(CaseMgr.regionMatches(src,false,0,s,k-sm1,sm1)) - return k-sm1-offset; - k += jump_ahead; - if(k > vend) return -1; - } - } + start += offset + sm1; + int vend = min(s.length() - 1, end + sm1 + offset), k; + int vend1 = vend - jump_ahead; + if (ign) + { + for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (anyc(s.charAt(k))) + { + if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; } - - return -1; + } + for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (anyc(s.charAt(k))) + { + if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + if (k > vend) + { + return -1; + } + } + } } - public int find(StringLike s,int start,int end) { - if(s instanceof StringWrap) - return find(s.toString(),start,end); - start += offset+sm1; - int vend = min(s.length()-1,end+sm1+offset),k; - int vend1 = vend-jump_ahead; - if(ign) { - for(k=start; k <= vend1;k += skip[s.charAt(k) & (MAX_CHAR-1)] ) { - // table look-up is expensive, avoid it if possible - if( anyc(s.charAt(k)) ) { - if(CaseMgr.regionMatches(src,ign,0,s,k-sm1,sm1)) - return k-sm1-offset; - k += jump_ahead; - } - } - for(; k <= vend;k += skip[s.charAt(k) & (MAX_CHAR-1)] ) { - // table look-up is expensive, avoid it if possible - if( anyc(s.charAt(k)) ) { - if(CaseMgr.regionMatches(src,ign,0,s,k-sm1,sm1)) - return k-sm1-offset; - k += jump_ahead; - if(k > vend) return -1; - } - } - } else { - for(k=start; k <= vend1;k += skip[s.charAt(k) & (MAX_CHAR-1)] ) { - // table look-up is expensive, avoid it if possible - if( x==s.charAt(k) ) { - //if(src.regionMatches(0,s,k-sm1,sm1)) - if(CaseMgr.regionMatches(src,false,0,s,k-sm1,sm1)) - return k-sm1-offset; - k += jump_ahead; - } - } - for(; k <= vend;k += skip[s.charAt(k) & (MAX_CHAR-1)] ) { - // table look-up is expensive, avoid it if possible - if( x==s.charAt(k) ) { - //if(src.regionMatches(0,s,k-sm1,sm1)) - if(CaseMgr.regionMatches(src,false,0,s,k-sm1,sm1)) - return k-sm1-offset; - k += jump_ahead; - if(k > vend) return -1; - } - } + else + { + for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (x == s.charAt(k)) + { + //if(src.regionMatches(0,s,k-sm1,sm1)) + if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; } - - return -1; + } + for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (x == s.charAt(k)) + { + //if(src.regionMatches(0,s,k-sm1,sm1)) + if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + if (k > vend) + { + return -1; + } + } + } } + + return -1; + } } diff --git a/src/com/stevesoft/pat/Skipped.java b/src/com/stevesoft/pat/Skipped.java index 9d963ae..9bf2837 100755 --- a/src/com/stevesoft/pat/Skipped.java +++ b/src/com/stevesoft/pat/Skipped.java @@ -6,22 +6,49 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** Implements the (?<number) Pattern, where number is an integer telling us how far to back up in the Pattern. Not in perl 5. */ -class Skipped extends Pattern { - String s; - Skipped(String s) { this.s = s; } - public String toString() { return s+nextString(); } - public int matchInternal(int pos,Pthings pt) { - //if(pt.no_check || s.regionMatches(pt.ignoreCase,0,pt.src,pos,s.length())) - if(pt.no_check || CaseMgr.regionMatches(s,pt.ignoreCase,0,pt.src,pos,s.length())) - return nextMatch(pos+s.length(),pt); - return -1; +class Skipped + extends Pattern +{ + String s; + Skipped(String s) + { + this.s = s; + } + + public String toString() + { + return s + nextString(); + } + + public int matchInternal(int pos, Pthings pt) + { + //if(pt.no_check || s.regionMatches(pt.ignoreCase,0,pt.src,pos,s.length())) + if (pt.no_check || + CaseMgr.regionMatches(s, pt.ignoreCase, 0, pt.src, pos, s.length())) + { + return nextMatch(pos + s.length(), pt); } - public patInt minChars() { return new patInt(s.length()); } - public patInt maxChars() { return new patInt(s.length()); } - Pattern clone1(Hashtable h) { return new Skipped(s); } + return -1; + } + + public patInt minChars() + { + return new patInt(s.length()); + } + + public patInt maxChars() + { + return new patInt(s.length()); + } + + Pattern clone1(Hashtable h) + { + return new Skipped(s); + } }; diff --git a/src/com/stevesoft/pat/SpecialRule.java b/src/com/stevesoft/pat/SpecialRule.java index 72df8d2..fbae452 100755 --- a/src/com/stevesoft/pat/SpecialRule.java +++ b/src/com/stevesoft/pat/SpecialRule.java @@ -7,7 +7,12 @@ // package com.stevesoft.pat; -public class SpecialRule extends ReplaceRule { - public SpecialRule() {} - public void apply(StringBufferLike sb,RegRes rr) {} +public class SpecialRule + extends ReplaceRule +{ + public SpecialRule() + {} + + public void apply(StringBufferLike sb, RegRes rr) + {} } diff --git a/src/com/stevesoft/pat/Start.java b/src/com/stevesoft/pat/Start.java index 9784358..c47ee53 100755 --- a/src/com/stevesoft/pat/Start.java +++ b/src/com/stevesoft/pat/Start.java @@ -6,26 +6,53 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** The '^' or the '\A' Pattern, matches the start of a string. */ -class Start extends Pattern { - boolean retIsStart; - Start(boolean b) { retIsStart = b; } - public int matchInternal(int pos,Pthings pt) { - if(retIsStart - && pt.mFlag - && pos > 0 && pt.src.charAt(pos-1)=='\n') - return nextMatch(pos,pt); - if(pos == 0) return nextMatch(pos,pt); - return -1; +class Start + extends Pattern +{ + boolean retIsStart; + Start(boolean b) + { + retIsStart = b; + } + + public int matchInternal(int pos, Pthings pt) + { + if (retIsStart + && pt.mFlag + && pos > 0 && pt.src.charAt(pos - 1) == '\n') + { + return nextMatch(pos, pt); } - public String toString() { - if(retIsStart) - return "^"+nextString(); - else - return "\\A"+nextString(); + if (pos == 0) + { + return nextMatch(pos, pt); + } + return -1; + } + + public String toString() + { + if (retIsStart) + { + return "^" + nextString(); } - public patInt maxChars() { return new patInt(0); } - Pattern clone1(Hashtable h) { return new Start(retIsStart); } + else + { + return "\\A" + nextString(); + } + } + + public patInt maxChars() + { + return new patInt(0); + } + + Pattern clone1(Hashtable h) + { + return new Start(retIsStart); + } }; diff --git a/src/com/stevesoft/pat/StrPos.java b/src/com/stevesoft/pat/StrPos.java index 6043625..d9383dd 100755 --- a/src/com/stevesoft/pat/StrPos.java +++ b/src/com/stevesoft/pat/StrPos.java @@ -6,111 +6,170 @@ // -- Happy Computing! // package com.stevesoft.pat; -/** + +/** Shareware: package pat Copyright 2001, Steven R. Brandt -*/ /** -StrPos is used internally by regex to parse the regular expression. */ -public class StrPos { - String s; - int pos; - /** Return the position in the string pointed to */ - public int pos() { return pos; } + */ +/** + StrPos is used internally by regex to parse the regular expression. */ +public class StrPos +{ + String s; + int pos; + /** Return the position in the string pointed to */ + public int pos() + { + return pos; + } + + /** This contains the escape character, which is \ by default. */ + public char esc = Pattern.ESC; + char c; + /** Returns the current, possibly escaped, character. */ + public char thisChar() + { + return c; + } + + boolean dontMatch, eos; - /** This contains the escape character, which is \ by default. */ - public char esc=Pattern.ESC; - char c; - /** Returns the current, possibly escaped, character. */ - public char thisChar() { return c; } + /** tell whether we are at end of string */ + public boolean eos() + { + return eos; + } - boolean dontMatch,eos; + /** initialize a StrPos from another StrPos. */ + public StrPos(StrPos sp) + { + dup(sp); + } - /** tell whether we are at end of string */ - public boolean eos() { return eos; } - /** initialize a StrPos from another StrPos. */ - public StrPos(StrPos sp) { - dup(sp); + /** copy a StrPos from sp to this. */ + public void dup(StrPos sp) + { + s = sp.s; + pos = sp.pos; + c = sp.c; + dontMatch = sp.dontMatch; + eos = sp.eos; + } + + /** Initialize a StrPos by giving it a String, and a + position within the String. */ + public StrPos(String s, int pos) + { + this.s = s; + this.pos = pos - 1; + inc(); + } + + /** Advance the place where StrPos points within the String. + Counts a backslash as part of the next character. */ + public StrPos inc() + { + pos++; + if (pos >= s.length()) + { + eos = true; + return this; } - /** copy a StrPos from sp to this. */ - public void dup(StrPos sp) { - s = sp.s; - pos = sp.pos; - c = sp.c; - dontMatch = sp.dontMatch; - eos = sp.eos; + eos = false; + c = s.charAt(pos); + if (c == esc && pos + 1 < s.length()) + { + pos++; + c = s.charAt(pos); + if (c != esc) + { + dontMatch = true; + } + else + { + dontMatch = false; + } } - /** Initialize a StrPos by giving it a String, and a - position within the String. */ - public StrPos(String s,int pos) { - this.s=s; - this.pos=pos-1; - inc(); + else + { + dontMatch = false; } - /** Advance the place where StrPos points within the String. - Counts a backslash as part of the next character. */ - public StrPos inc() { - pos++; - if(pos >= s.length()) { - eos = true; - return this; - } - eos = false; - c = s.charAt(pos); - if(c == esc && pos+1st that matches a non-escaped + character. */ + public boolean incMatch(String st) + { + StrPos sp = new StrPos(this); + int i; + for (i = 0; i < st.length(); i++) + { + if (!sp.match(st.charAt(i))) + { + return false; + } + sp.inc(); } + dup(sp); + return true; + } - /** Returns true if the current - character is escaped (preceeded by "\"). */ - public boolean escaped() { return dontMatch; } - /** Increment the string pointer by each character in -

st
that matches a non-escaped - character. */ - public boolean incMatch(String st) { - StrPos sp = new StrPos(this); - int i; - for(i=0;i= '0' && sp.c <= '9';i++) { - cnt = 10*cnt+sp.c-'0'; - sp.inc(); - } - if(i==0) return null; - dup(sp); - return new patInt(cnt); + int i, cnt = 0; + StrPos sp = new StrPos(this); + for (i = 0; !sp.eos && sp.c >= '0' && sp.c <= '9'; i++) + { + cnt = 10 * cnt + sp.c - '0'; + sp.inc(); } - /** get the string that we are processing. */ - public String getString() { return s; } + if (i == 0) + { + return null; + } + dup(sp); + return new patInt(cnt); + } + + /** get the string that we are processing. */ + public String getString() + { + return s; + } }; diff --git a/src/com/stevesoft/pat/StringBufferLike.java b/src/com/stevesoft/pat/StringBufferLike.java index 18fa994..96d2178 100755 --- a/src/com/stevesoft/pat/StringBufferLike.java +++ b/src/com/stevesoft/pat/StringBufferLike.java @@ -1,64 +1,90 @@ -package// +package // // This software is now distributed according to // the Lesser Gnu Public License. Please see // http://www.gnu.org/copyleft/lesser.txt for // the details. // -- Happy Computing! // -com.stevesoft.pat; - + com.stevesoft.pat; /** A tool that is used to make the \E, \U, \L, and \Q elements of a substitution. */ -public class StringBufferLike implements BasicStringBufferLike { +public class StringBufferLike + implements BasicStringBufferLike +{ BasicStringBufferLike sbl; - public StringBufferLike(BasicStringBufferLike sbl) { + public StringBufferLike(BasicStringBufferLike sbl) + { this.sbl = sbl; } + char mode = 'E', altMode = ' '; - public StringLike toStringLike() { + public StringLike toStringLike() + { return sbl.toStringLike(); } - public String toString() { + + public String toString() + { return sbl.toString(); } - public void append(char c) { - - switch(mode) { - case 'u': - mode = altMode; - altMode = ' '; - case 'U': - sbl.append(CaseMgr.toUpperCase(c)); - break; - case 'l': - mode = altMode; - altMode = ' '; - case 'L': - sbl.append(CaseMgr.toLowerCase(c)); - break; - case 'Q': - if((c >= 'a' && c <= 'z') - || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9')) - ; - else - sbl.append('\\'); - default: - sbl.append(c); - break; + + public void append(char c) + { + + switch (mode) + { + case 'u': + mode = altMode; + altMode = ' '; + case 'U': + sbl.append(CaseMgr.toUpperCase(c)); + break; + case 'l': + mode = altMode; + altMode = ' '; + case 'L': + sbl.append(CaseMgr.toLowerCase(c)); + break; + case 'Q': + if ( (c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9')) + { + ; + } + else + { + sbl.append('\\'); + } + default: + sbl.append(c); + break; } } - public void append(String s) { - for(int i=0;i= 0) { - pn = i; - return r; - } - } - pn = -1; - return -1; + int lastMatchedTo = -1; + public int matchInternal(int pos, Pthings pt) + { + for (int i = 0; i < ra_len; i++) + { + pt.ignoreCase = ra[i].ignoreCase; + pt.mFlag = ra[i].mFlag; + pt.dotDoesntMatchCR = Regex.dotDoesntMatchCR; + int r = ra[i].thePattern.matchInternal(pos, pt); + if (r >= 0) + { + pn = i; + return r; + } } + pn = -1; + return -1; + } } diff --git a/src/com/stevesoft/pat/Transformer.java b/src/com/stevesoft/pat/Transformer.java index 14f7e38..843fbfa 100755 --- a/src/com/stevesoft/pat/Transformer.java +++ b/src/com/stevesoft/pat/Transformer.java @@ -7,20 +7,35 @@ // package com.stevesoft.pat; -import com.stevesoft.pat.wrap.StringWrap; +import com.stevesoft.pat.wrap.*; /** Replacement rule used by the Transformer. @see com.stevesoft.pat.Transformer - */ -class TransRepRule extends ReplaceRule { - Transformer t; - TransRepRule(Transformer t) { this.t = t; } - public String toString1() { return ""; } - public Object clone1() { return new TransRepRule(t); } - public void apply(StringBufferLike sb,RegRes rr) { - // get the ReplaceRule of the Regex that matched. - next = t.tp.ra[t.tp.pn].getReplaceRule(); - } + */ +class TransRepRule + extends ReplaceRule +{ + Transformer t; + TransRepRule(Transformer t) + { + this.t = t; + } + + public String toString1() + { + return ""; + } + + public Object clone1() + { + return new TransRepRule(t); + } + + public void apply(StringBufferLike sb, RegRes rr) + { + // get the ReplaceRule of the Regex that matched. + next = t.tp.ra[t.tp.pn].getReplaceRule(); + } } /** Sometimes you want to replace a whole bunch of things @@ -42,113 +57,163 @@ class TransRepRule extends ReplaceRule {

So far, at least, this class does not have the capability of turning into a giant robot :-) - */ -public class Transformer { - TransPat tp; - Regex rp = new Regex(); - boolean auto_optimize; - - /** Get a replacer to that works with the current Regex. - @see com.stevesoft.pat.Replacer - */ - public Replacer getReplacer() { return rp.getReplacer(); } - - /** Instantiate a new Transformer object. */ - public Transformer(boolean auto) { - auto_optimize = auto; - tp = new TransPat(); - rp.setReplaceRule(new TransRepRule(this)); - rp.thePattern = tp; - } + */ +public class Transformer +{ + TransPat tp; + Regex rp = new Regex(); + boolean auto_optimize; - /** Add a new Regex to the set of Regex's. */ - public void add(Regex r) { - if(auto_optimize) r.optimize(); - tp.ra[tp.ra_len++] = r; - if(tp.ra.length==tp.ra_len) { - Regex[] ra2 = new Regex[tp.ra_len+10]; - for(int i=0;i rp.numSubs_ ? r.numSubs_ : rp.numSubs_; - } + /** Get a replacer to that works with the current Regex. + @see com.stevesoft.pat.Replacer + */ + public Replacer getReplacer() + { + return rp.getReplacer(); + } - /** Returns the number of Regex's in this Transformer. */ - public int patterns() { return tp.ra_len; } + /** Instantiate a new Transformer object. */ + public Transformer(boolean auto) + { + auto_optimize = auto; + tp = new TransPat(); + rp.setReplaceRule(new TransRepRule(this)); + rp.thePattern = tp; + } - /** Get the Regex at position i in this Transformer. */ - public Regex getRegexAt(int i) { - if(i >= tp.ra_len) - throw new ArrayIndexOutOfBoundsException("i="+i+">="+patterns()); - if(i < 0) - throw new ArrayIndexOutOfBoundsException("i="+i+"< 0"); - return tp.ra[i]; - } - /** Set the Regex at position i in this Transformer. */ - public void setRegexAt(Regex rx,int i) { - if(i >= tp.ra_len) - throw new ArrayIndexOutOfBoundsException("i="+i+">="+patterns()); - if(i < 0) - throw new ArrayIndexOutOfBoundsException("i="+i+"< 0"); - tp.ra[i] = rx; - } + /** Add a new Regex to the set of Regex's. */ + public void add(Regex r) + { + if (auto_optimize) + { + r.optimize(); + } + tp.ra[tp.ra_len++] = r; + if (tp.ra.length == tp.ra_len) + { + Regex[] ra2 = new Regex[tp.ra_len + 10]; + for (int i = 0; i < tp.ra_len; i++) + { + ra2[i] = tp.ra[i]; + } + tp.ra = ra2; + } + rp.numSubs_ = r.numSubs_ > rp.numSubs_ ? r.numSubs_ : rp.numSubs_; + } - /** Add a new Regex by calling Regex.perlCode - @see com.stevesoft.pat.Regex#perlCode(java.lang.String) - */ - public void add(String rs) { - Regex r = Regex.perlCode(rs); - if(r == null) throw new NullPointerException("bad pattern to Regex.perlCode: "+rs); - add(r); - } - /** Add an array of Strings (which will be converted to - Regex's via the Regex.perlCode method. - @see com.stevesoft.pat.Regex#perlCode(java.lang.String) - */ - public void add(String[] array) { - for(int i=0;i= tp.ra_len) + { + throw new ArrayIndexOutOfBoundsException("i=" + i + ">=" + patterns()); + } + if (i < 0) + { + throw new ArrayIndexOutOfBoundsException("i=" + i + "< 0"); + } + return tp.ra[i]; + } - /** Replace the first matching pattern in String s. */ - public String replaceFirst(String s) { - return dorep(s,0,s.length()); - } - /** Replace the first matching pattern after position start in - String s. */ - public String replaceFirstFrom(String s,int start) { - return dorep(s,start,s.length()); - } - /** Replace the first matching pattern that begins between - start and end inclusive. */ - public String replaceFirstRegion(String s,int start,int end) { - return dorep(s,start,end); - } + /** Set the Regex at position i in this Transformer. */ + public void setRegexAt(Regex rx, int i) + { + if (i >= tp.ra_len) + { + throw new ArrayIndexOutOfBoundsException("i=" + i + ">=" + patterns()); + } + if (i < 0) + { + throw new ArrayIndexOutOfBoundsException("i=" + i + "< 0"); + } + tp.ra[i] = rx; + } + + /** Add a new Regex by calling Regex.perlCode + @see com.stevesoft.pat.Regex#perlCode(java.lang.String) + */ + public void add(String rs) + { + Regex r = Regex.perlCode(rs); + if (r == null) + { + throw new NullPointerException("bad pattern to Regex.perlCode: " + rs); + } + add(r); + } + + /** Add an array of Strings (which will be converted to + Regex's via the Regex.perlCode method. + @see com.stevesoft.pat.Regex#perlCode(java.lang.String) + */ + public void add(String[] array) + { + for (int i = 0; i < array.length; i++) + { + add(array[i]); + } + } + + /** Replace all matches in the current String. */ + public String replaceAll(String s) + { + return dorep(s, 0, s.length()); + } + + public StringLike replaceAll(StringLike s) + { + return dorep(s, 0, s.length()); + } + + /** Replace all matching patterns beginning at position start. */ + public String replaceAllFrom(String s, int start) + { + return dorep(s, start, s.length()); + } + + /** Replace all matching patterns beginning between the positions + start and end inclusive. */ + public String replaceAllRegion(String s, int start, int end) + { + return dorep(s, start, end); + } + + Replacer repr = new Replacer(); + final StringLike dorep(StringLike s, int start, int end) + { + StringLike tfmd = repr.replaceAllRegion(s, rp, start, end); + tp.lastMatchedTo = repr.lastMatchedTo; + return tfmd; + } + + final String dorep(String s, int start, int end) + { + return dorep(new StringWrap(s), start, end).toString(); + } + + /** Replace the first matching pattern in String s. */ + public String replaceFirst(String s) + { + return dorep(s, 0, s.length()); + } + + /** Replace the first matching pattern after position start in + String s. */ + public String replaceFirstFrom(String s, int start) + { + return dorep(s, start, s.length()); + } + + /** Replace the first matching pattern that begins between + start and end inclusive. */ + public String replaceFirstRegion(String s, int start, int end) + { + return dorep(s, start, end); + } } diff --git a/src/com/stevesoft/pat/UniValidator.java b/src/com/stevesoft/pat/UniValidator.java index 7fbac56..4d86074 100755 --- a/src/com/stevesoft/pat/UniValidator.java +++ b/src/com/stevesoft/pat/UniValidator.java @@ -8,9 +8,18 @@ package com.stevesoft.pat; /** This provides a base class for all the Unicode character - * matching rules. - */ -class UniValidator extends Validator { - public patInt minChars() { return new patInt(1); } - public patInt maxChars() { return new patInt(1); } + * matching rules. + */ +class UniValidator + extends Validator +{ + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } } diff --git a/src/com/stevesoft/pat/Validator.java b/src/com/stevesoft/pat/Validator.java index facd3f7..34b07da 100755 --- a/src/com/stevesoft/pat/Validator.java +++ b/src/com/stevesoft/pat/Validator.java @@ -8,51 +8,63 @@ package com.stevesoft.pat; /** This class makes it easy to create your own patterns -and integrate them into Regex. For more detail, see the -example file deriv2.java or -deriv3.java. */ + and integrate them into Regex. For more detail, see the + example file deriv2.java or + deriv3.java. */ -public class Validator { - String argsave = null; - String pattern = "."; - /** - This method does extra checking on a matched section of - a String beginning at position start and ending at end. - The idea is that you can do extra checking with this - that you don't know how to do with a standard Regex. +public class Validator +{ + String argsave = null; + String pattern = "."; + /** + This method does extra checking on a matched section of + a String beginning at position start and ending at end. + The idea is that you can do extra checking with this + that you don't know how to do with a standard Regex. - If this method is successful, it returns the location - of the end of this pattern element -- that may be the - value end provided or some other value. A negative - value signifies that a match failure. - - By default, this method just returns end and thus - does nothing. - @see com.stevesoft.pat.Regex#define(java.lang.String,java.lang.String,com.stevesoft.pat.Validator) - */ - public int validate(StringLike src,int start,int end) { - return end; - } - /* This method allows you to modify the behavior of this - validator by making a new Validator object. If a Validator - named "foo" is defined, then the pattern "{??foo:bar}" will - cause Regex to first get the Validator given to Regex.define - and then to call its arg method with the string "bar". - If this method returns a null (the default) you get the same - behavior as the pattern "{??foo}" would supply. */ - public Validator arg(String s) { return null; } + If this method is successful, it returns the location + of the end of this pattern element -- that may be the + value end provided or some other value. A negative + value signifies that a match failure. - /** For optimization it is helpful, but not necessary, that - you define the minimum number of characters this validator - will allow to match. To do this - return new patInt(number) where number is the smallest - number of characters that can match. */ - public patInt minChars() { return new patInt(0); } + By default, this method just returns end and thus + does nothing. + @see com.stevesoft.pat.Regex#define(java.lang.String,java.lang.String,com.stevesoft.pat.Validator) + */ + public int validate(StringLike src, int start, int end) + { + return end; + } - /** For optimization it is helpful, but not necessary, that - you define the maximum number of characters this validator - will allow to match. To do this either - return new patInt(number), or new patInf() if an infinite - number of characters may match. */ - public patInt maxChars() { return new patInf(); } + /* This method allows you to modify the behavior of this + validator by making a new Validator object. If a Validator + named "foo" is defined, then the pattern "{??foo:bar}" will + cause Regex to first get the Validator given to Regex.define + and then to call its arg method with the string "bar". + If this method returns a null (the default) you get the same + behavior as the pattern "{??foo}" would supply. */ + public Validator arg(String s) + { + return null; + } + + /** For optimization it is helpful, but not necessary, that + you define the minimum number of characters this validator + will allow to match. To do this + return new patInt(number) where number is the smallest + number of characters that can match. */ + public patInt minChars() + { + return new patInt(0); + } + + /** For optimization it is helpful, but not necessary, that + you define the maximum number of characters this validator + will allow to match. To do this either + return new patInt(number), or new patInf() if an infinite + number of characters may match. */ + public patInt maxChars() + { + return new patInf(); + } } diff --git a/src/com/stevesoft/pat/WantMoreTextReplaceRule.java b/src/com/stevesoft/pat/WantMoreTextReplaceRule.java index 5cc6722..34b73e5 100755 --- a/src/com/stevesoft/pat/WantMoreTextReplaceRule.java +++ b/src/com/stevesoft/pat/WantMoreTextReplaceRule.java @@ -10,10 +10,19 @@ package com.stevesoft.pat; /** Triggers the reading of another line of text, allowing a longer pattern to match -- for details see WantMore.java. - */ -public class WantMoreTextReplaceRule extends SpecialRule { - public WantMoreTextReplaceRule() {} - public void apply(StringBufferLike sb,RegRes res) { - } - public String toString1() { return "${WANT_MORE_TEXT}"; } + */ +public class WantMoreTextReplaceRule + extends SpecialRule +{ + public WantMoreTextReplaceRule() + {} + + public void apply(StringBufferLike sb, RegRes res) + { + } + + public String toString1() + { + return "${WANT_MORE_TEXT}"; + } } diff --git a/src/com/stevesoft/pat/lookAhead.java b/src/com/stevesoft/pat/lookAhead.java index 112db7c..73be36a 100755 --- a/src/com/stevesoft/pat/lookAhead.java +++ b/src/com/stevesoft/pat/lookAhead.java @@ -6,41 +6,94 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** Implements "(?= )" and "(?! )" */ -class lookAhead extends Or { - boolean reverse; - lookAhead(boolean b) { reverse = b; } - public Pattern getNext() { return null; } - public int nextMatch(int pos,Pthings pt) { - Pattern p = super.getNext(); - if(p != null) return p.matchInternal(pos,pt); - else return pos; +class lookAhead + extends Or +{ + boolean reverse; + lookAhead(boolean b) + { + reverse = b; + } + + public Pattern getNext() + { + return null; + } + + public int nextMatch(int pos, Pthings pt) + { + Pattern p = super.getNext(); + if (p != null) + { + return p.matchInternal(pos, pt); } - public int matchInternal(int pos,Pthings pt) { - if(super.matchInternal(pos,pt) >= 0) { - if(reverse) return -1; - else return nextMatch(pos,pt); - } else { - if(reverse) return nextMatch(pos,pt); - else return -1; - } + else + { + return pos; } - String leftForm() { - if(reverse) - return "(?!"; - else - return "(?="; + } + + public int matchInternal(int pos, Pthings pt) + { + if (super.matchInternal(pos, pt) >= 0) + { + if (reverse) + { + return -1; + } + else + { + return nextMatch(pos, pt); + } + } + else + { + if (reverse) + { + return nextMatch(pos, pt); + } + else + { + return -1; + } } - public patInt minChars() { return new patInt(0); } - public patInt maxChars() { return new patInt(0); } - Pattern clone1(Hashtable h) { - lookAhead la=new lookAhead(reverse); - h.put(this,la); - h.put(la,la); - for(int i=0;i'; - if(c == '[') - return ']'; - if(c == '(') - return ')'; - if(c == '{') - return '}'; - return c; + of Regex.perlCode. + @see Regex#perlCode + */ +class parsePerl +{ + final static char close(char c) + { + // This switch statement does not behave + // properly when compiled with jdk1.1.5 + // and the -O flag. + /* + switch(c) { + case '[': + return ']'; + case '(': + return ')'; + case '{': + return '}'; + } + return c;*/ + if (c == '<') + { + return '>'; } - - final public static String codify(String s,boolean keepbs) { - return codify(s,0,s.length(),keepbs); + if (c == '[') + { + return ']'; + } + if (c == '(') + { + return ')'; + } + if (c == '{') + { + return '}'; } - final public static String codify(String s,int i0,int iN,boolean keepbs) { - StringBuffer sb = new StringBuffer(); - boolean ucmode = false, lcmode = false, litmode = false; - boolean uc1 = false, lc1 = false; - boolean modified = false; - for(int i=i0;i= 'a' && c <= 'z') + { + return false; } - final static char uc(char c) { - return CaseMgr.toUpperCase(c); + if (c >= 'A' && c <= 'Z') + { + return false; } - final static char lc(char c) { - return CaseMgr.toLowerCase(c); + if (c >= '0' && c <= '9') + { + return false; } - final static boolean needbs(char c) { - if(c >= 'a' && c <= 'z') - return false; - if(c >= 'A' && c <= 'Z') - return false; - if(c >= '0' && c <= '9') - return false; - if(c == '_') - return false; - return true; + if (c == '_') + { + return false; } - final static Regex parse(String s) { - boolean igncase = false, optim = false, gFlag = false; - boolean sFlag = false, mFlag = false, xFlag = false; + return true; + } - StringBuffer s1 = new StringBuffer(); - StringBuffer s2 = new StringBuffer(); - int i=0,count=0; - char mode,delim='/',cdelim='/'; - if(s.length() >= 3 && s.charAt(0)=='s') { - mode = 's'; - delim = s.charAt(1); - cdelim = close(delim); - i=2; - } else if(s.length() >= 2 && s.charAt(0)=='m') { - mode = 'm'; - delim = s.charAt(1); - cdelim = close(delim); - i=2; - } else if(s.length() >= 1 && s.charAt(0)=='/') { - mode = 'm'; - i=1; - } else { - try { - RegSyntaxError.endItAll( - "Regex.perlCode should be of the "+ - "form s/// or m// or //"); - } catch(RegSyntax rs) {} - return null; - } - for(;i= 3 && s.charAt(0) == 's') + { + mode = 's'; + delim = s.charAt(1); + cdelim = close(delim); + i = 2; + } + else if (s.length() >= 2 && s.charAt(0) == 'm') + { + mode = 'm'; + delim = s.charAt(1); + cdelim = close(delim); + i = 2; + } + else if (s.length() >= 1 && s.charAt(0) == '/') + { + mode = 'm'; + i = 1; + } + else + { + try + { + RegSyntaxError.endItAll( + "Regex.perlCode should be of the " + + "form s/// or m// or //"); + } + catch (RegSyntax rs) + {} + return null; + } + for (; i < s.length(); i++) + { + if (s.charAt(i) == '\\') + { + s1.append('\\'); + i++; + } + else if (s.charAt(i) == cdelim && count == 0) + { + i++; + break; + } + else if (s.charAt(i) == delim && cdelim != delim) + { + count++; + } + else if (s.charAt(i) == cdelim && cdelim != delim) + { + count--; + } + s1.append(s.charAt(i)); + } + if (mode == 's' && cdelim != delim) + { + while (i < s.length() && Prop.isWhite(s.charAt(i))) + { + i++; + } + if (i >= s.length()) + { + try + { + RegSyntaxError.endItAll("" + mode + delim + " needs " + cdelim); } - if(mode=='s' && cdelim != delim) { - while(i=s.length()) { - try { - RegSyntaxError.endItAll(""+mode+delim+" needs "+cdelim); - } catch(RegSyntax rs) {} - return null; - } - cdelim = close(delim = s.charAt(i)); - i++; + catch (RegSyntax rs) + {} + return null; + } + cdelim = close(delim = s.charAt(i)); + i++; + } + count = 0; + if (mode == 's') + { + for (; i < s.length(); i++) + { + if (s.charAt(i) == '\\') + { + s2.append('\\'); + i++; } - count=0; - if(mode=='s') { - for(;i i) i = p.i; - return this; + setInf(false); + return this; + } + + /** If the argument p has a greater than this, + then set this object equal to p. */ + public final patInt maxeq(patInt p) + { + if (inf || p.inf) + { + setInf(true); + return this; + } + if (p.i > i) + { + i = p.i; } - /** Tests to see if this represents an infinite quantity. */ - public boolean finite() { return !inf; } - /** Converts to a patInt to an int. Infinity is - mapped Integer.MAX_VALUE; - */ - public int intValue() { return inf ? Integer.MAX_VALUE : i; } + return this; + } + + /** Tests to see if this represents an infinite quantity. */ + public boolean finite() + { + return!inf; + } + + /** Converts to a patInt to an int. Infinity is + mapped Integer.MAX_VALUE; + */ + public int intValue() + { + return inf ? Integer.MAX_VALUE : i; + } }; diff --git a/src/com/stevesoft/pat/wrap/CharArrayBufferWrap.java b/src/com/stevesoft/pat/wrap/CharArrayBufferWrap.java index 4e11067..19f268e 100755 --- a/src/com/stevesoft/pat/wrap/CharArrayBufferWrap.java +++ b/src/com/stevesoft/pat/wrap/CharArrayBufferWrap.java @@ -1,38 +1,53 @@ -package// +package // // This software is now distributed according to // the Lesser Gnu Public License. Please see // http://www.gnu.org/copyleft/lesser.txt for // the details. // -- Happy Computing! // -com.stevesoft.pat.wrap; + com.stevesoft.pat.wrap; import com.stevesoft.pat.*; /** Allows the outcome of a replaceAll() or replaceFirst() to be an array of characters rather than a String. - */ + */ public class CharArrayBufferWrap - implements BasicStringBufferLike - { + implements BasicStringBufferLike +{ StringBuffer sb = new StringBuffer(); - public void append(char c) { + public void append(char c) + { sb.append(c); } - public void append(String s) { + + public void append(String s) + { sb.append(s); } - public StringLike toStringLike() { + + public StringLike toStringLike() + { char[] ca = new char[sb.length()]; - for(int i=0;i= i0 && i < iend) + { + return (char) buf[i - i0]; } - public char charAt(int i) { - if(i >= i0 && i < iend) - return (char)buf[i-i0]; - - try { - i0 = i-5; - //if(i0+offset<0) i0=(int)(-offset); - if(i0<0) i0=0; - raf.seek(i0+offset); - iend = i0+raf.read(buf,0,buf.length); - - if(i >= i0 && i < iend) - return (char)buf[i-i0]; - } catch(Throwable t) {} - - throw new ArrayIndexOutOfBoundsException("Out of bounds for file:"+ - " i="+i+ - ", Final Buffer: i0="+i0+ - " iend="+iend); + try + { + i0 = i - 5; + //if(i0+offset<0) i0=(int)(-offset); + if (i0 < 0) + { + i0 = 0; + } + raf.seek(i0 + offset); + iend = i0 + raf.read(buf, 0, buf.length); + + if (i >= i0 && i < iend) + { + return (char) buf[i - i0]; + } } + catch (Throwable t) + {} - public String toString() { throw new Error("Not implemented"); } - public int length() { - try { - long len = raf.length()-offset; - if(len > Integer.MAX_VALUE) - return Integer.MAX_VALUE; - return (int)len; - } catch(IOException ioe) { - return 0; + throw new ArrayIndexOutOfBoundsException("Out of bounds for file:" + + " i=" + i + + ", Final Buffer: i0=" + i0 + + " iend=" + iend); + } + + public String toString() + { + throw new Error("Not implemented"); + } + + public int length() + { + try + { + long len = raf.length() - offset; + if (len > Integer.MAX_VALUE) + { + return Integer.MAX_VALUE; } + return (int) len; } - public String substring(int i1,int i2) { - StringBuffer sb = new StringBuffer(); - for(int i=i1;i @@ -17,29 +18,42 @@ import java.io.*; This means that the return value of replaceAll() will be null if this Object is used as the StringBufferLike.*/ public class WriterWrap - implements BasicStringBufferLike - { + implements BasicStringBufferLike +{ Writer w; - public WriterWrap(Writer w) { + public WriterWrap(Writer w) + { this.w = w; } - public void append(char c) { - try { - w.write((int)c); - } catch(IOException ioe) {} + + public void append(char c) + { + try + { + w.write( (int) c); + } + catch (IOException ioe) + {} } - public void append(String s) { - try { + + public void append(String s) + { + try + { w.write(s); - } catch(IOException ioe) {} + } + catch (IOException ioe) + {} } /** This operation can't really be done. */ - public StringLike toStringLike() { + public StringLike toStringLike() + { return null; } - public Object unwrap() { + public Object unwrap() + { return w; } } diff --git a/src/ext/vamsas/IRegistry.java b/src/ext/vamsas/IRegistry.java index afddded..9300f59 100755 --- a/src/ext/vamsas/IRegistry.java +++ b/src/ext/vamsas/IRegistry.java @@ -7,6 +7,9 @@ package ext.vamsas; -public interface IRegistry extends java.rmi.Remote { - public ext.vamsas.ServiceHandles getServices() throws java.rmi.RemoteException; +public interface IRegistry + extends java.rmi.Remote +{ + public ext.vamsas.ServiceHandles getServices() + throws java.rmi.RemoteException; } diff --git a/src/ext/vamsas/IRegistryService.java b/src/ext/vamsas/IRegistryService.java index 9f09f02..2590314 100755 --- a/src/ext/vamsas/IRegistryService.java +++ b/src/ext/vamsas/IRegistryService.java @@ -7,10 +7,14 @@ package ext.vamsas; -public interface IRegistryService extends javax.xml.rpc.Service { - public java.lang.String getRegistryServiceAddress(); +public interface IRegistryService + extends javax.xml.rpc.Service +{ + public java.lang.String getRegistryServiceAddress(); - public ext.vamsas.IRegistry getRegistryService() throws javax.xml.rpc.ServiceException; + public ext.vamsas.IRegistry getRegistryService() + throws javax.xml.rpc.ServiceException; - public ext.vamsas.IRegistry getRegistryService(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; + public ext.vamsas.IRegistry getRegistryService(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException; } diff --git a/src/ext/vamsas/IRegistryServiceLocator.java b/src/ext/vamsas/IRegistryServiceLocator.java index b3aa85d..0d7c0da 100755 --- a/src/ext/vamsas/IRegistryServiceLocator.java +++ b/src/ext/vamsas/IRegistryServiceLocator.java @@ -7,130 +7,175 @@ package ext.vamsas; -public class IRegistryServiceLocator extends org.apache.axis.client.Service implements ext.vamsas.IRegistryService { - - public IRegistryServiceLocator() { +public class IRegistryServiceLocator + extends org.apache.axis.client.Service implements ext.vamsas. + IRegistryService +{ + + public IRegistryServiceLocator() + { + } + + public IRegistryServiceLocator(org.apache.axis.EngineConfiguration config) + { + super(config); + } + + // Use to get a proxy class for RegistryService + private java.lang.String RegistryService_address = "http://webservices.compbio.dundee.ac.uk:8080/jalTestWS/services/RegistryService"; + + public java.lang.String getRegistryServiceAddress() + { + return RegistryService_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String RegistryServiceWSDDServiceName = "RegistryService"; + + public java.lang.String getRegistryServiceWSDDServiceName() + { + return RegistryServiceWSDDServiceName; + } + + public void setRegistryServiceWSDDServiceName(java.lang.String name) + { + RegistryServiceWSDDServiceName = name; + } + + public ext.vamsas.IRegistry getRegistryService() + throws javax.xml.rpc.ServiceException + { + java.net.URL endpoint; + try + { + endpoint = new java.net.URL(RegistryService_address); } - - - public IRegistryServiceLocator(org.apache.axis.EngineConfiguration config) { - super(config); + catch (java.net.MalformedURLException e) + { + throw new javax.xml.rpc.ServiceException(e); } - - // Use to get a proxy class for RegistryService - private java.lang.String RegistryService_address = "http://webservices.compbio.dundee.ac.uk:8080/jalTestWS/services/RegistryService"; - - public java.lang.String getRegistryServiceAddress() { - return RegistryService_address; + return getRegistryService(endpoint); + } + + public ext.vamsas.IRegistry getRegistryService(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException + { + try + { + ext.vamsas.RegistryServiceSoapBindingStub _stub = new ext.vamsas. + RegistryServiceSoapBindingStub(portAddress, this); + _stub.setPortName(getRegistryServiceWSDDServiceName()); + return _stub; } - - // The WSDD service name defaults to the port name. - private java.lang.String RegistryServiceWSDDServiceName = "RegistryService"; - - public java.lang.String getRegistryServiceWSDDServiceName() { - return RegistryServiceWSDDServiceName; + catch (org.apache.axis.AxisFault e) + { + return null; } - - public void setRegistryServiceWSDDServiceName(java.lang.String name) { - RegistryServiceWSDDServiceName = name; + } + + public void setRegistryServiceEndpointAddress(java.lang.String address) + { + RegistryService_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + try + { + if (ext.vamsas.IRegistry.class.isAssignableFrom(serviceEndpointInterface)) + { + ext.vamsas.RegistryServiceSoapBindingStub _stub = new ext.vamsas. + RegistryServiceSoapBindingStub(new java.net.URL( + RegistryService_address), this); + _stub.setPortName(getRegistryServiceWSDDServiceName()); + return _stub; + } } - - public ext.vamsas.IRegistry getRegistryService() throws javax.xml.rpc.ServiceException { - java.net.URL endpoint; - try { - endpoint = new java.net.URL(RegistryService_address); - } - catch (java.net.MalformedURLException e) { - throw new javax.xml.rpc.ServiceException(e); - } - return getRegistryService(endpoint); + catch (java.lang.Throwable t) + { + throw new javax.xml.rpc.ServiceException(t); } - - public ext.vamsas.IRegistry getRegistryService(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { - try { - ext.vamsas.RegistryServiceSoapBindingStub _stub = new ext.vamsas.RegistryServiceSoapBindingStub(portAddress, this); - _stub.setPortName(getRegistryServiceWSDDServiceName()); - return _stub; - } - catch (org.apache.axis.AxisFault e) { - return null; - } - } - - public void setRegistryServiceEndpointAddress(java.lang.String address) { - RegistryService_address = address; + throw new javax.xml.rpc.ServiceException( + "There is no stub implementation for the interface: " + + (serviceEndpointInterface == null ? "null" : + serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, + Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + if (portName == null) + { + return getPort(serviceEndpointInterface); } - - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - try { - if (ext.vamsas.IRegistry.class.isAssignableFrom(serviceEndpointInterface)) { - ext.vamsas.RegistryServiceSoapBindingStub _stub = new ext.vamsas.RegistryServiceSoapBindingStub(new java.net.URL(RegistryService_address), this); - _stub.setPortName(getRegistryServiceWSDDServiceName()); - return _stub; - } - } - catch (java.lang.Throwable t) { - throw new javax.xml.rpc.ServiceException(t); - } - throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + java.lang.String inputPortName = portName.getLocalPart(); + if ("RegistryService".equals(inputPortName)) + { + return getRegistryService(); } - - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - if (portName == null) { - return getPort(serviceEndpointInterface); - } - java.lang.String inputPortName = portName.getLocalPart(); - if ("RegistryService".equals(inputPortName)) { - return getRegistryService(); - } - else { - java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ((org.apache.axis.client.Stub) _stub).setPortName(portName); - return _stub; - } + else + { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ( (org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; } + } - public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("vamsas", "IRegistryService"); - } + public javax.xml.namespace.QName getServiceName() + { + return new javax.xml.namespace.QName("vamsas", "IRegistryService"); + } - private java.util.HashSet ports = null; + private java.util.HashSet ports = null; - public java.util.Iterator getPorts() { - if (ports == null) { - ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("vamsas", "RegistryService")); - } - return ports.iterator(); + public java.util.Iterator getPorts() + { + if (ports == null) + { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("vamsas", "RegistryService")); } - - /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - if ("RegistryService".equals(portName)) { - setRegistryServiceEndpointAddress(address); - } - else { // Unknown Port Name - throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); - } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, + java.lang.String address) + throws javax.xml.rpc.ServiceException + { + if ("RegistryService".equals(portName)) + { + setRegistryServiceEndpointAddress(address); } - - /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - setEndpointAddress(portName.getLocalPart(), address); + else + { // Unknown Port Name + throw new javax.xml.rpc.ServiceException( + " Cannot set Endpoint Address for Unknown Port" + portName); } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, + java.lang.String address) + throws javax.xml.rpc.ServiceException + { + setEndpointAddress(portName.getLocalPart(), address); + } } diff --git a/src/ext/vamsas/Jpred.java b/src/ext/vamsas/Jpred.java index 4860339..c3ab28b 100755 --- a/src/ext/vamsas/Jpred.java +++ b/src/ext/vamsas/Jpred.java @@ -7,9 +7,18 @@ package ext.vamsas; -public interface Jpred extends java.rmi.Remote { - public java.lang.String predict(vamsas.objects.simple.Sequence seq) throws java.rmi.RemoteException; - public java.lang.String predictOnMsa(vamsas.objects.simple.Msfalignment msf) throws java.rmi.RemoteException; - public vamsas.objects.simple.Secstructpred getpredict(java.lang.String job_id) throws java.rmi.RemoteException; - public vamsas.objects.simple.JpredResult getresult(java.lang.String job_id) throws java.rmi.RemoteException; +public interface Jpred + extends java.rmi.Remote +{ + public java.lang.String predict(vamsas.objects.simple.Sequence seq) + throws java.rmi.RemoteException; + + public java.lang.String predictOnMsa(vamsas.objects.simple.Msfalignment msf) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.Secstructpred getpredict(java.lang.String job_id) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.JpredResult getresult(java.lang.String job_id) + throws java.rmi.RemoteException; } diff --git a/src/ext/vamsas/JpredService.java b/src/ext/vamsas/JpredService.java index 0b95e68..8917d77 100755 --- a/src/ext/vamsas/JpredService.java +++ b/src/ext/vamsas/JpredService.java @@ -7,10 +7,14 @@ package ext.vamsas; -public interface JpredService extends javax.xml.rpc.Service { - public java.lang.String getjpredAddress(); +public interface JpredService + extends javax.xml.rpc.Service +{ + public java.lang.String getjpredAddress(); - public ext.vamsas.Jpred getjpred() throws javax.xml.rpc.ServiceException; + public ext.vamsas.Jpred getjpred() + throws javax.xml.rpc.ServiceException; - public ext.vamsas.Jpred getjpred(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; + public ext.vamsas.Jpred getjpred(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException; } diff --git a/src/ext/vamsas/JpredServiceLocator.java b/src/ext/vamsas/JpredServiceLocator.java index 813c340..433fa70 100755 --- a/src/ext/vamsas/JpredServiceLocator.java +++ b/src/ext/vamsas/JpredServiceLocator.java @@ -7,130 +7,174 @@ package ext.vamsas; -public class JpredServiceLocator extends org.apache.axis.client.Service implements ext.vamsas.JpredService { - - public JpredServiceLocator() { +public class JpredServiceLocator + extends org.apache.axis.client.Service implements ext.vamsas.JpredService +{ + + public JpredServiceLocator() + { + } + + public JpredServiceLocator(org.apache.axis.EngineConfiguration config) + { + super(config); + } + + // Use to get a proxy class for jpred + private java.lang.String jpred_address = + "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; + + public java.lang.String getjpredAddress() + { + return jpred_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String jpredWSDDServiceName = "jpred"; + + public java.lang.String getjpredWSDDServiceName() + { + return jpredWSDDServiceName; + } + + public void setjpredWSDDServiceName(java.lang.String name) + { + jpredWSDDServiceName = name; + } + + public ext.vamsas.Jpred getjpred() + throws javax.xml.rpc.ServiceException + { + java.net.URL endpoint; + try + { + endpoint = new java.net.URL(jpred_address); } - - - public JpredServiceLocator(org.apache.axis.EngineConfiguration config) { - super(config); + catch (java.net.MalformedURLException e) + { + throw new javax.xml.rpc.ServiceException(e); } - - // Use to get a proxy class for jpred - private java.lang.String jpred_address = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; - - public java.lang.String getjpredAddress() { - return jpred_address; + return getjpred(endpoint); + } + + public ext.vamsas.Jpred getjpred(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException + { + try + { + ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas. + JpredSoapBindingStub(portAddress, this); + _stub.setPortName(getjpredWSDDServiceName()); + return _stub; } - - // The WSDD service name defaults to the port name. - private java.lang.String jpredWSDDServiceName = "jpred"; - - public java.lang.String getjpredWSDDServiceName() { - return jpredWSDDServiceName; + catch (org.apache.axis.AxisFault e) + { + return null; } - - public void setjpredWSDDServiceName(java.lang.String name) { - jpredWSDDServiceName = name; + } + + public void setjpredEndpointAddress(java.lang.String address) + { + jpred_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + try + { + if (ext.vamsas.Jpred.class.isAssignableFrom(serviceEndpointInterface)) + { + ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas. + JpredSoapBindingStub(new java.net.URL(jpred_address), this); + _stub.setPortName(getjpredWSDDServiceName()); + return _stub; + } } - - public ext.vamsas.Jpred getjpred() throws javax.xml.rpc.ServiceException { - java.net.URL endpoint; - try { - endpoint = new java.net.URL(jpred_address); - } - catch (java.net.MalformedURLException e) { - throw new javax.xml.rpc.ServiceException(e); - } - return getjpred(endpoint); + catch (java.lang.Throwable t) + { + throw new javax.xml.rpc.ServiceException(t); } - - public ext.vamsas.Jpred getjpred(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { - try { - ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.JpredSoapBindingStub(portAddress, this); - _stub.setPortName(getjpredWSDDServiceName()); - return _stub; - } - catch (org.apache.axis.AxisFault e) { - return null; - } - } - - public void setjpredEndpointAddress(java.lang.String address) { - jpred_address = address; + throw new javax.xml.rpc.ServiceException( + "There is no stub implementation for the interface: " + + (serviceEndpointInterface == null ? "null" : + serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, + Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + if (portName == null) + { + return getPort(serviceEndpointInterface); } - - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - try { - if (ext.vamsas.Jpred.class.isAssignableFrom(serviceEndpointInterface)) { - ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.JpredSoapBindingStub(new java.net.URL(jpred_address), this); - _stub.setPortName(getjpredWSDDServiceName()); - return _stub; - } - } - catch (java.lang.Throwable t) { - throw new javax.xml.rpc.ServiceException(t); - } - throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); + java.lang.String inputPortName = portName.getLocalPart(); + if ("jpred".equals(inputPortName)) + { + return getjpred(); } - - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - if (portName == null) { - return getPort(serviceEndpointInterface); - } - java.lang.String inputPortName = portName.getLocalPart(); - if ("jpred".equals(inputPortName)) { - return getjpred(); - } - else { - java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ((org.apache.axis.client.Stub) _stub).setPortName(portName); - return _stub; - } + else + { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ( (org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; } + } - public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("vamsas", "jpredService"); - } + public javax.xml.namespace.QName getServiceName() + { + return new javax.xml.namespace.QName("vamsas", "jpredService"); + } - private java.util.HashSet ports = null; + private java.util.HashSet ports = null; - public java.util.Iterator getPorts() { - if (ports == null) { - ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("vamsas", "jpred")); - } - return ports.iterator(); + public java.util.Iterator getPorts() + { + if (ports == null) + { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("vamsas", "jpred")); } - - /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - if ("jpred".equals(portName)) { - setjpredEndpointAddress(address); - } - else { // Unknown Port Name - throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); - } + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, + java.lang.String address) + throws javax.xml.rpc.ServiceException + { + if ("jpred".equals(portName)) + { + setjpredEndpointAddress(address); } - - /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - setEndpointAddress(portName.getLocalPart(), address); + else + { // Unknown Port Name + throw new javax.xml.rpc.ServiceException( + " Cannot set Endpoint Address for Unknown Port" + portName); } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, + java.lang.String address) + throws javax.xml.rpc.ServiceException + { + setEndpointAddress(portName.getLocalPart(), address); + } } diff --git a/src/ext/vamsas/JpredSoapBindingStub.java b/src/ext/vamsas/JpredSoapBindingStub.java index a42bc49..4c8fc7f 100755 --- a/src/ext/vamsas/JpredSoapBindingStub.java +++ b/src/ext/vamsas/JpredSoapBindingStub.java @@ -7,293 +7,389 @@ package ext.vamsas; -public class JpredSoapBindingStub extends org.apache.axis.client.Stub implements ext.vamsas.Jpred { - private java.util.Vector cachedSerClasses = new java.util.Vector(); - private java.util.Vector cachedSerQNames = new java.util.Vector(); - private java.util.Vector cachedSerFactories = new java.util.Vector(); - private java.util.Vector cachedDeserFactories = new java.util.Vector(); +public class JpredSoapBindingStub + extends org.apache.axis.client.Stub implements ext.vamsas.Jpred +{ + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); - static org.apache.axis.description.OperationDesc [] _operations; + static org.apache.axis.description.OperationDesc[] _operations; - static { - _operations = new org.apache.axis.description.OperationDesc[4]; - _initOperationDesc1(); - } + static + { + _operations = new org.apache.axis.description.OperationDesc[4]; + _initOperationDesc1(); + } - private static void _initOperationDesc1(){ - org.apache.axis.description.OperationDesc oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("predict"); - oper.addParameter(new javax.xml.namespace.QName("", "seq"), new javax.xml.namespace.QName("simple.objects.vamsas", "Sequence"), vamsas.objects.simple.Sequence.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - oper.setReturnClass(java.lang.String.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "predictReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[0] = oper; + private static void _initOperationDesc1() + { + org.apache.axis.description.OperationDesc oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("predict"); + oper.addParameter(new javax.xml.namespace.QName("", "seq"), + new javax.xml. + namespace.QName("simple.objects.vamsas", "Sequence"), + vamsas.objects.simple.Sequence.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "predictReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[0] = oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("predictOnMsa"); - oper.addParameter(new javax.xml.namespace.QName("", "msf"), new javax.xml.namespace.QName("http://simple.objects.vamsas", "Msfalignment"), vamsas.objects.simple.Msfalignment.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - oper.setReturnClass(java.lang.String.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "predictOnMsaReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[1] = oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("predictOnMsa"); + oper.addParameter(new javax.xml.namespace.QName("", "msf"), + new javax.xml. + namespace.QName("http://simple.objects.vamsas", + "Msfalignment"), + vamsas.objects.simple.Msfalignment.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "predictOnMsaReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[1] = oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getpredict"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("http://simple.objects.vamsas", "Secstructpred")); - oper.setReturnClass(vamsas.objects.simple.Secstructpred.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getpredictReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[2] = oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getpredict"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax. + xml.namespace.QName("http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "http://simple.objects.vamsas", "Secstructpred")); + oper.setReturnClass(vamsas.objects.simple.Secstructpred.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "getpredictReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[2] = oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getresult"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("http://simple.objects.vamsas", "JpredResult")); - oper.setReturnClass(vamsas.objects.simple.JpredResult.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getresultReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[3] = oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getresult"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax. + xml.namespace.QName("http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "http://simple.objects.vamsas", "JpredResult")); + oper.setReturnClass(vamsas.objects.simple.JpredResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "getresultReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[3] = oper; - } + } - public JpredSoapBindingStub() throws org.apache.axis.AxisFault { - this(null); - } + public JpredSoapBindingStub() + throws org.apache.axis.AxisFault + { + this(null); + } - public JpredSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - this(service); - super.cachedEndpoint = endpointURL; - } + public JpredSoapBindingStub(java.net.URL endpointURL, + javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault + { + this(service); + super.cachedEndpoint = endpointURL; + } - public JpredSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - if (service == null) { - super.service = new org.apache.axis.client.Service(); - } else { - super.service = service; - } - java.lang.Class cls; - javax.xml.namespace.QName qName; - java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; - /*java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; - java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class;*/ - qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", "JpredResult"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.JpredResult.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); + public JpredSoapBindingStub(javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault + { + if (service == null) + { + super.service = new org.apache.axis.client.Service(); + } + else + { + super.service = service; + } + java.lang.Class cls; + javax.xml.namespace.QName qName; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser. + BeanDeserializerFactory.class; + /*java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class;*/ + qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", + "JpredResult"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.JpredResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Result.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); + qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Result.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); - qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", "Secstructpred"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Secstructpred.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); + qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", + "Secstructpred"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Secstructpred.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); - qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", "Msfalignment"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Msfalignment.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); + qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", + "Msfalignment"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Msfalignment.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); + qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); - } + } - protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { - try { - org.apache.axis.client.Call _call = - (org.apache.axis.client.Call) super.service.createCall(); - if (super.maintainSessionSet) { - _call.setMaintainSession(super.maintainSession); - } - if (super.cachedUsername != null) { - _call.setUsername(super.cachedUsername); - } - if (super.cachedPassword != null) { - _call.setPassword(super.cachedPassword); - } - if (super.cachedEndpoint != null) { - _call.setTargetEndpointAddress(super.cachedEndpoint); - } - if (super.cachedTimeout != null) { - _call.setTimeout(super.cachedTimeout); - } - if (super.cachedPortName != null) { - _call.setPortName(super.cachedPortName); - } - java.util.Enumeration keys = super.cachedProperties.keys(); - while (keys.hasMoreElements()) { - java.lang.String key = (java.lang.String) keys.nextElement(); - _call.setProperty(key, super.cachedProperties.get(key)); - } - // All the type mapping information is registered - // when the first call is made. - // The type mapping information is actually registered in - // the TypeMappingRegistry of the service, which - // is the reason why registration is only needed for the first call. - synchronized (this) { - if (firstCall()) { - // must set encoding style before registering serializers - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); - for (int i = 0; i < cachedSerFactories.size(); ++i) { - java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = - (javax.xml.namespace.QName) cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) - cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) - cachedDeserFactories.get(i); - _call.registerTypeMapping(cls, qName, sf, df, false); - } - } - } - return _call; - } - catch (java.lang.Throwable _t) { - throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); + protected org.apache.axis.client.Call createCall() + throws java.rmi.RemoteException + { + try + { + org.apache.axis.client.Call _call = + (org.apache.axis.client.Call)super.service.createCall(); + if (super.maintainSessionSet) + { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) + { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) + { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) + { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) + { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) + { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) + { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) + { + if (firstCall()) + { + // must set encoding style before registering serializers + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants. + SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + for (int i = 0; i < cachedSerFactories.size(); ++i) + { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } } + } + return _call; + } + catch (java.lang.Throwable _t) + { + throw new org.apache.axis.AxisFault( + "Failure trying to get the Call object", _t); } + } - public java.lang.String predict(vamsas.objects.simple.Sequence seq) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[0]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "predict")); + public java.lang.String predict(vamsas.objects.simple.Sequence seq) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", "predict")); - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {seq}); + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {seq}); - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (java.lang.String) _resp; - } catch (java.lang.Exception _exception) { - return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); - } - } + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + try + { + return (java.lang.String) _resp; + } + catch (java.lang.Exception _exception) + { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, + java.lang.String.class); + } } + } - public java.lang.String predictOnMsa(vamsas.objects.simple.Msfalignment msf) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[1]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "predictOnMsa")); + public java.lang.String predictOnMsa(vamsas.objects.simple.Msfalignment msf) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "predictOnMsa")); - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {msf}); + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {msf}); - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (java.lang.String) _resp; - } catch (java.lang.Exception _exception) { - return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); - } - } + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; } + else + { + extractAttachments(_call); + try + { + return (java.lang.String) _resp; + } + catch (java.lang.Exception _exception) + { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, + java.lang.String.class); + } + } + } - public vamsas.objects.simple.Secstructpred getpredict(java.lang.String job_id) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[2]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getpredict")); + public vamsas.objects.simple.Secstructpred getpredict(java.lang.String job_id) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getpredict")); - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {job_id}); + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {job_id}); - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.Secstructpred) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.Secstructpred) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.Secstructpred.class); - } - } + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + try + { + return (vamsas.objects.simple.Secstructpred) _resp; + } + catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.Secstructpred) org.apache.axis.utils. + JavaUtils.convert(_resp, vamsas.objects.simple.Secstructpred.class); + } } + } - public vamsas.objects.simple.JpredResult getresult(java.lang.String job_id) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[3]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getresult")); + public vamsas.objects.simple.JpredResult getresult(java.lang.String job_id) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getresult")); - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {job_id}); + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {job_id}); - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.JpredResult) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.JpredResult) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.JpredResult.class); - } - } + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + try + { + return (vamsas.objects.simple.JpredResult) _resp; + } + catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.JpredResult) org.apache.axis.utils. + JavaUtils.convert(_resp, vamsas.objects.simple.JpredResult.class); + } } + } } diff --git a/src/ext/vamsas/MuscleWS.java b/src/ext/vamsas/MuscleWS.java index 970ec72..db1416e 100755 --- a/src/ext/vamsas/MuscleWS.java +++ b/src/ext/vamsas/MuscleWS.java @@ -6,36 +6,38 @@ */ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package ext.vamsas; -public interface MuscleWS extends java.rmi.Remote { - public vamsas.objects.simple.WsJobId align( - vamsas.objects.simple.SequenceSet seqSet) - throws java.rmi.RemoteException; +public interface MuscleWS + extends java.rmi.Remote +{ + public vamsas.objects.simple.WsJobId align( + vamsas.objects.simple.SequenceSet seqSet) + throws java.rmi.RemoteException; - public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) - throws java.rmi.RemoteException; + public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) + throws java.rmi.RemoteException; - public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) - throws java.rmi.RemoteException; + public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) + throws java.rmi.RemoteException; - public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) - throws java.rmi.RemoteException; + public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) + throws java.rmi.RemoteException; } diff --git a/src/ext/vamsas/MuscleWSService.java b/src/ext/vamsas/MuscleWSService.java index bf6d26a..a4dc674 100755 --- a/src/ext/vamsas/MuscleWSService.java +++ b/src/ext/vamsas/MuscleWSService.java @@ -6,31 +6,33 @@ */ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package ext.vamsas; -public interface MuscleWSService extends javax.xml.rpc.Service { - public java.lang.String getMuscleWSAddress(); +public interface MuscleWSService + extends javax.xml.rpc.Service +{ + public java.lang.String getMuscleWSAddress(); - public ext.vamsas.MuscleWS getMuscleWS() - throws javax.xml.rpc.ServiceException; + public ext.vamsas.MuscleWS getMuscleWS() + throws javax.xml.rpc.ServiceException; - public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) - throws javax.xml.rpc.ServiceException; + public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException; } diff --git a/src/ext/vamsas/MuscleWSServiceLocator.java b/src/ext/vamsas/MuscleWSServiceLocator.java index 80a2f96..a269029 100755 --- a/src/ext/vamsas/MuscleWSServiceLocator.java +++ b/src/ext/vamsas/MuscleWSServiceLocator.java @@ -6,163 +6,203 @@ */ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package ext.vamsas; -public class MuscleWSServiceLocator extends org.apache.axis.client.Service - implements ext.vamsas.MuscleWSService { - // Use to get a proxy class for MuscleWS - private java.lang.String MuscleWS_address = "http://anaplog.compbio.dundee.ac.uk:8080/axis/services/MuscleWS"; - - // The WSDD service name defaults to the port name. - private java.lang.String MuscleWSWSDDServiceName = "MuscleWS"; - private java.util.HashSet ports = null; - - public MuscleWSServiceLocator() { +public class MuscleWSServiceLocator + extends org.apache.axis.client.Service implements ext.vamsas. + MuscleWSService +{ + // Use to get a proxy class for MuscleWS + private java.lang.String MuscleWS_address = + "http://anaplog.compbio.dundee.ac.uk:8080/axis/services/MuscleWS"; + + // The WSDD service name defaults to the port name. + private java.lang.String MuscleWSWSDDServiceName = "MuscleWS"; + private java.util.HashSet ports = null; + + public MuscleWSServiceLocator() + { + } + + public MuscleWSServiceLocator(org.apache.axis.EngineConfiguration config) + { + super(config); + } + + public java.lang.String getMuscleWSAddress() + { + return MuscleWS_address; + } + + public java.lang.String getMuscleWSWSDDServiceName() + { + return MuscleWSWSDDServiceName; + } + + public void setMuscleWSWSDDServiceName(java.lang.String name) + { + MuscleWSWSDDServiceName = name; + } + + public ext.vamsas.MuscleWS getMuscleWS() + throws javax.xml.rpc.ServiceException + { + java.net.URL endpoint; + + try + { + endpoint = new java.net.URL(MuscleWS_address); } - - public MuscleWSServiceLocator(org.apache.axis.EngineConfiguration config) { - super(config); + catch (java.net.MalformedURLException e) + { + throw new javax.xml.rpc.ServiceException(e); } - public java.lang.String getMuscleWSAddress() { - return MuscleWS_address; - } + return getMuscleWS(endpoint); + } - public java.lang.String getMuscleWSWSDDServiceName() { - return MuscleWSWSDDServiceName; - } + public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException + { + try + { + ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas. + MuscleWSSoapBindingStub(portAddress, + this); + _stub.setPortName(getMuscleWSWSDDServiceName()); - public void setMuscleWSWSDDServiceName(java.lang.String name) { - MuscleWSWSDDServiceName = name; + return _stub; } - - public ext.vamsas.MuscleWS getMuscleWS() - throws javax.xml.rpc.ServiceException { - java.net.URL endpoint; - - try { - endpoint = new java.net.URL(MuscleWS_address); - } catch (java.net.MalformedURLException e) { - throw new javax.xml.rpc.ServiceException(e); - } - - return getMuscleWS(endpoint); + catch (org.apache.axis.AxisFault e) + { + return null; } - - public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) - throws javax.xml.rpc.ServiceException { - try { - ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas.MuscleWSSoapBindingStub(portAddress, - this); - _stub.setPortName(getMuscleWSWSDDServiceName()); - - return _stub; - } catch (org.apache.axis.AxisFault e) { - return null; - } + } + + public void setMuscleWSEndpointAddress(java.lang.String address) + { + MuscleWS_address = address; + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + try + { + if (ext.vamsas.MuscleWS.class.isAssignableFrom( + serviceEndpointInterface)) + { + ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas. + MuscleWSSoapBindingStub(new java.net.URL( + MuscleWS_address), this); + _stub.setPortName(getMuscleWSWSDDServiceName()); + + return _stub; + } } - - public void setMuscleWSEndpointAddress(java.lang.String address) { - MuscleWS_address = address; + catch (java.lang.Throwable t) + { + throw new javax.xml.rpc.ServiceException(t); } - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(Class serviceEndpointInterface) - throws javax.xml.rpc.ServiceException { - try { - if (ext.vamsas.MuscleWS.class.isAssignableFrom( - serviceEndpointInterface)) { - ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas.MuscleWSSoapBindingStub(new java.net.URL( - MuscleWS_address), this); - _stub.setPortName(getMuscleWSWSDDServiceName()); - - return _stub; - } - } catch (java.lang.Throwable t) { - throw new javax.xml.rpc.ServiceException(t); - } - - throw new javax.xml.rpc.ServiceException( - "There is no stub implementation for the interface: " + - ((serviceEndpointInterface == null) ? "null" - : serviceEndpointInterface.getName())); + throw new javax.xml.rpc.ServiceException( + "There is no stub implementation for the interface: " + + ( (serviceEndpointInterface == null) ? "null" + : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, + Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + if (portName == null) + { + return getPort(serviceEndpointInterface); } - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(javax.xml.namespace.QName portName, - Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - if (portName == null) { - return getPort(serviceEndpointInterface); - } - - java.lang.String inputPortName = portName.getLocalPart(); - - if ("MuscleWS".equals(inputPortName)) { - return getMuscleWS(); - } else { - java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ((org.apache.axis.client.Stub) _stub).setPortName(portName); - - return _stub; - } - } + java.lang.String inputPortName = portName.getLocalPart(); - public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("vamsas", "MuscleWSService"); + if ("MuscleWS".equals(inputPortName)) + { + return getMuscleWS(); } + else + { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ( (org.apache.axis.client.Stub) _stub).setPortName(portName); - public java.util.Iterator getPorts() { - if (ports == null) { - ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("vamsas", "MuscleWS")); - } - - return ports.iterator(); + return _stub; } - - /** -* Set the endpoint address for the specified port name. -*/ - public void setEndpointAddress(java.lang.String portName, - java.lang.String address) throws javax.xml.rpc.ServiceException { - if ("MuscleWS".equals(portName)) { - setMuscleWSEndpointAddress(address); - } else { // Unknown Port Name - throw new javax.xml.rpc.ServiceException( - " Cannot set Endpoint Address for Unknown Port" + portName); - } + } + + public javax.xml.namespace.QName getServiceName() + { + return new javax.xml.namespace.QName("vamsas", "MuscleWSService"); + } + + public java.util.Iterator getPorts() + { + if (ports == null) + { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("vamsas", "MuscleWS")); } - /** -* Set the endpoint address for the specified port name. -*/ - public void setEndpointAddress(javax.xml.namespace.QName portName, - java.lang.String address) throws javax.xml.rpc.ServiceException { - setEndpointAddress(portName.getLocalPart(), address); + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, + java.lang.String address) + throws javax.xml.rpc.ServiceException + { + if ("MuscleWS".equals(portName)) + { + setMuscleWSEndpointAddress(address); + } + else + { // Unknown Port Name + throw new javax.xml.rpc.ServiceException( + " Cannot set Endpoint Address for Unknown Port" + portName); } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, + java.lang.String address) + throws javax.xml.rpc.ServiceException + { + setEndpointAddress(portName.getLocalPart(), address); + } } diff --git a/src/ext/vamsas/MuscleWSSoapBindingStub.java b/src/ext/vamsas/MuscleWSSoapBindingStub.java index ace12f4..de80f9e 100755 --- a/src/ext/vamsas/MuscleWSSoapBindingStub.java +++ b/src/ext/vamsas/MuscleWSSoapBindingStub.java @@ -6,389 +6,465 @@ */ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package ext.vamsas; -public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub - implements ext.vamsas.MuscleWS { - static org.apache.axis.description.OperationDesc[] _operations; - - static { - _operations = new org.apache.axis.description.OperationDesc[4]; - _initOperationDesc1(); +public class MuscleWSSoapBindingStub + extends org.apache.axis.client.Stub implements ext.vamsas.MuscleWS +{ + static org.apache.axis.description.OperationDesc[] _operations; + + static + { + _operations = new org.apache.axis.description.OperationDesc[4]; + _initOperationDesc1(); + } + + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + public MuscleWSSoapBindingStub() + throws org.apache.axis.AxisFault + { + this(null); + } + + public MuscleWSSoapBindingStub(java.net.URL endpointURL, + javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault + { + this(service); + super.cachedEndpoint = endpointURL; + } + + public MuscleWSSoapBindingStub(javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault + { + if (service == null) + { + super.service = new org.apache.axis.client.Service(); } - - private java.util.Vector cachedSerClasses = new java.util.Vector(); - private java.util.Vector cachedSerQNames = new java.util.Vector(); - private java.util.Vector cachedSerFactories = new java.util.Vector(); - private java.util.Vector cachedDeserFactories = new java.util.Vector(); - - public MuscleWSSoapBindingStub() throws org.apache.axis.AxisFault { - this(null); - } - - public MuscleWSSoapBindingStub(java.net.URL endpointURL, - javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - this(service); - super.cachedEndpoint = endpointURL; + else + { + super.service = service; } - public MuscleWSSoapBindingStub(javax.xml.rpc.Service service) - throws org.apache.axis.AxisFault { - if (service == null) { - super.service = new org.apache.axis.client.Service(); - } else { - super.service = service; + java.lang.Class cls; + javax.xml.namespace.QName qName; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser. + BeanDeserializerFactory.class; + //java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + //java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser. + ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser. + ArrayDeserializerFactory.class; + //java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + // java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + //java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + //java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "MsaResult"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.MsaResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "SequenceSet"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.SequenceSet.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", + "Object"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Object.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Alignment"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Alignment.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.WsJobId.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_xsd_string"); + cachedSerQNames.add(qName); + cls = java.lang.String[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Result.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + } + + private static void _initOperationDesc1() + { + org.apache.axis.description.OperationDesc oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("align"); + oper.addParameter(new javax.xml.namespace.QName("", "seqSet"), + new javax.xml.namespace.QName("simple.objects.vamsas", + "SequenceSet"), + vamsas.objects.simple.SequenceSet.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "alignReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getalign"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "Alignment")); + oper.setReturnClass(vamsas.objects.simple.Alignment.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "getalignReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getResult"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "MsaResult")); + oper.setReturnClass(vamsas.objects.simple.MsaResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "getResultReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("cancel"); + oper.addParameter(new javax.xml.namespace.QName("", "jobId"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "cancelReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[3] = oper; + } + + protected org.apache.axis.client.Call createCall() + throws java.rmi.RemoteException + { + try + { + org.apache.axis.client.Call _call = (org.apache.axis.client.Call)super. + service.createCall(); + + if (super.maintainSessionSet) + { + _call.setMaintainSession(super.maintainSession); + } + + if (super.cachedUsername != null) + { + _call.setUsername(super.cachedUsername); + } + + if (super.cachedPassword != null) + { + _call.setPassword(super.cachedPassword); + } + + if (super.cachedEndpoint != null) + { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + + if (super.cachedTimeout != null) + { + _call.setTimeout(super.cachedTimeout); + } + + if (super.cachedPortName != null) + { + _call.setPortName(super.cachedPortName); + } + + java.util.Enumeration keys = super.cachedProperties.keys(); + + while (keys.hasMoreElements()) + { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) + { + if (firstCall()) + { + // must set encoding style before registering serializers + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants. + SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + + for (int i = 0; i < cachedSerFactories.size(); ++i) + { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = (javax.xml.namespace.QName) + cachedSerQNames.get(i); + java.lang.Class sf = (java.lang.Class) cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } } + } - java.lang.Class cls; - javax.xml.namespace.QName qName; - java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; - //java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - //java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; - //java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - // java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - //java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - //java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; - qName = new javax.xml.namespace.QName("simple.objects.vamsas", - "Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", - "MsaResult"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.MsaResult.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", - "SequenceSet"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.SequenceSet.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", - "Object"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Object.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", - "Alignment"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Alignment.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.WsJobId.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_xsd_string"); - cachedSerQNames.add(qName); - cls = java.lang.String[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Result.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); + return _call; } - - private static void _initOperationDesc1() { - org.apache.axis.description.OperationDesc oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("align"); - oper.addParameter(new javax.xml.namespace.QName("", "seqSet"), - new javax.xml.namespace.QName("simple.objects.vamsas", "SequenceSet"), - vamsas.objects.simple.SequenceSet.class, - org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName( - "simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "alignReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[0] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getalign"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), - new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", - "string"), java.lang.String.class, - org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName( - "simple.objects.vamsas", "Alignment")); - oper.setReturnClass(vamsas.objects.simple.Alignment.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getalignReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[1] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getResult"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), - new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", - "string"), java.lang.String.class, - org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName( - "simple.objects.vamsas", "MsaResult")); - oper.setReturnClass(vamsas.objects.simple.MsaResult.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getResultReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[2] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("cancel"); - oper.addParameter(new javax.xml.namespace.QName("", "jobId"), - new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", - "string"), java.lang.String.class, - org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName( - "simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "cancelReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[3] = oper; + catch (java.lang.Throwable _t) + { + throw new org.apache.axis.AxisFault( + "Failure trying to get the Call object", + _t); } - - protected org.apache.axis.client.Call createCall() - throws java.rmi.RemoteException { - try { - org.apache.axis.client.Call _call = (org.apache.axis.client.Call) super.service.createCall(); - - if (super.maintainSessionSet) { - _call.setMaintainSession(super.maintainSession); - } - - if (super.cachedUsername != null) { - _call.setUsername(super.cachedUsername); - } - - if (super.cachedPassword != null) { - _call.setPassword(super.cachedPassword); - } - - if (super.cachedEndpoint != null) { - _call.setTargetEndpointAddress(super.cachedEndpoint); - } - - if (super.cachedTimeout != null) { - _call.setTimeout(super.cachedTimeout); - } - - if (super.cachedPortName != null) { - _call.setPortName(super.cachedPortName); - } - - java.util.Enumeration keys = super.cachedProperties.keys(); - - while (keys.hasMoreElements()) { - java.lang.String key = (java.lang.String) keys.nextElement(); - _call.setProperty(key, super.cachedProperties.get(key)); - } - - // All the type mapping information is registered - // when the first call is made. - // The type mapping information is actually registered in - // the TypeMappingRegistry of the service, which - // is the reason why registration is only needed for the first call. - synchronized (this) { - if (firstCall()) { - // must set encoding style before registering serializers - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); - - for (int i = 0; i < cachedSerFactories.size(); ++i) { - java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) cachedDeserFactories.get(i); - _call.registerTypeMapping(cls, qName, sf, df, false); - } - } - } - - return _call; - } catch (java.lang.Throwable _t) { - throw new org.apache.axis.AxisFault("Failure trying to get the Call object", - _t); - } + } + + public vamsas.objects.simple.WsJobId align( + vamsas.objects.simple.SequenceSet seqSet) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); } - public vamsas.objects.simple.WsJobId align( - vamsas.objects.simple.SequenceSet seqSet) - throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[0]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "align")); - - setRequestHeaders(_call); - setAttachments(_call); + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", "align")); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] { seqSet }); + setRequestHeaders(_call); + setAttachments(_call); - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException) _resp; - } else { - extractAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {seqSet}); - try { - return (vamsas.objects.simple.WsJobId) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + + try + { + return (vamsas.objects.simple.WsJobId) _resp; + } + catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils. + convert(_resp, vamsas.objects.simple.WsJobId.class); - } - } + } + } + } + + public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); } - public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) - throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getalign")); - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[1]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", - "getalign")); - - setRequestHeaders(_call); - setAttachments(_call); - - java.lang.Object _resp = _call.invoke(new java.lang.Object[] { job_id }); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException) _resp; - } else { - extractAttachments(_call); - - try { - return (vamsas.objects.simple.Alignment) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.Alignment) org.apache.axis.utils.JavaUtils.convert(_resp, - vamsas.objects.simple.Alignment.class); - } - } - } + setRequestHeaders(_call); + setAttachments(_call); - public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) - throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {job_id}); - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[2]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", - "getResult")); - - setRequestHeaders(_call); - setAttachments(_call); - - java.lang.Object _resp = _call.invoke(new java.lang.Object[] { job_id }); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException) _resp; - } else { - extractAttachments(_call); - - try { - return (vamsas.objects.simple.MsaResult) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.MsaResult) org.apache.axis.utils.JavaUtils.convert(_resp, - vamsas.objects.simple.MsaResult.class); - } - } + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + + try + { + return (vamsas.objects.simple.Alignment) _resp; + } + catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.Alignment) org.apache.axis.utils. + JavaUtils.convert(_resp, + vamsas.objects.simple.Alignment.class); + } + } + } + + public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); } - public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) - throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getResult")); + + setRequestHeaders(_call); + setAttachments(_call); - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[3]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "cancel")); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {job_id}); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + + try + { + return (vamsas.objects.simple.MsaResult) _resp; + } + catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.MsaResult) org.apache.axis.utils. + JavaUtils.convert(_resp, + vamsas.objects.simple.MsaResult.class); + } + } + } + + public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } - setRequestHeaders(_call); - setAttachments(_call); + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", "cancel")); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] { jobId }); + setRequestHeaders(_call); + setAttachments(_call); - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException) _resp; - } else { - extractAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {jobId}); - try { - return (vamsas.objects.simple.WsJobId) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + + try + { + return (vamsas.objects.simple.WsJobId) _resp; + } + catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils. + convert(_resp, vamsas.objects.simple.WsJobId.class); - } - } + } } + } } diff --git a/src/ext/vamsas/RegistryServiceSoapBindingStub.java b/src/ext/vamsas/RegistryServiceSoapBindingStub.java index 6379c0c..22bd8ed 100755 --- a/src/ext/vamsas/RegistryServiceSoapBindingStub.java +++ b/src/ext/vamsas/RegistryServiceSoapBindingStub.java @@ -7,164 +7,212 @@ package ext.vamsas; -public class RegistryServiceSoapBindingStub extends org.apache.axis.client.Stub implements ext.vamsas.IRegistry { - private java.util.Vector cachedSerClasses = new java.util.Vector(); - private java.util.Vector cachedSerQNames = new java.util.Vector(); - private java.util.Vector cachedSerFactories = new java.util.Vector(); - private java.util.Vector cachedDeserFactories = new java.util.Vector(); - - static org.apache.axis.description.OperationDesc [] _operations; - - static { - _operations = new org.apache.axis.description.OperationDesc[1]; - _initOperationDesc1(); +public class RegistryServiceSoapBindingStub + extends org.apache.axis.client.Stub implements ext.vamsas.IRegistry +{ + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc[] _operations; + + static + { + _operations = new org.apache.axis.description.OperationDesc[1]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1() + { + org.apache.axis.description.OperationDesc oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getServices"); + oper.setReturnType(new javax.xml.namespace.QName("registry.objects.vamsas", + "ServiceHandles")); + oper.setReturnClass(ext.vamsas.ServiceHandles.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "getServicesReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[0] = oper; + + } + + public RegistryServiceSoapBindingStub() + throws org.apache.axis.AxisFault + { + this(null); + } + + public RegistryServiceSoapBindingStub(java.net.URL endpointURL, + javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault + { + this(service); + super.cachedEndpoint = endpointURL; + } + + public RegistryServiceSoapBindingStub(javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault + { + if (service == null) + { + super.service = new org.apache.axis.client.Service(); } - - private static void _initOperationDesc1(){ - org.apache.axis.description.OperationDesc oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getServices"); - oper.setReturnType(new javax.xml.namespace.QName("registry.objects.vamsas", "ServiceHandles")); - oper.setReturnClass(ext.vamsas.ServiceHandles.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getServicesReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[0] = oper; - + else + { + super.service = service; } - - public RegistryServiceSoapBindingStub() throws org.apache.axis.AxisFault { - this(null); + java.lang.Class cls; + javax.xml.namespace.QName qName; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser. + BeanDeserializerFactory.class; + //java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + //java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser. + ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser. + ArrayDeserializerFactory.class; + //java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + //java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + //java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + //java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("vamsas", + "ArrayOf_tns1_ServiceHandle"); + cachedSerQNames.add(qName); + cls = ext.vamsas.ServiceHandle[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("registry.objects.vamsas", + "ServiceHandles"); + cachedSerQNames.add(qName); + cls = ext.vamsas.ServiceHandles.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("registry.objects.vamsas", + "ServiceHandle"); + cachedSerQNames.add(qName); + cls = ext.vamsas.ServiceHandle.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() + throws java.rmi.RemoteException + { + try + { + org.apache.axis.client.Call _call = + (org.apache.axis.client.Call)super.service.createCall(); + if (super.maintainSessionSet) + { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) + { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) + { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) + { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) + { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) + { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) + { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) + { + if (firstCall()) + { + // must set encoding style before registering serializers + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants. + SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + for (int i = 0; i < cachedSerFactories.size(); ++i) + { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = + (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Class sf = (java.lang.Class) + cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) + cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + return _call; } - - public RegistryServiceSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - this(service); - super.cachedEndpoint = endpointURL; + catch (java.lang.Throwable _t) + { + throw new org.apache.axis.AxisFault( + "Failure trying to get the Call object", _t); } - - public RegistryServiceSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - if (service == null) { - super.service = new org.apache.axis.client.Service(); - } else { - super.service = service; - } - java.lang.Class cls; - javax.xml.namespace.QName qName; - java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; - //java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - //java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; - //java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - //java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - //java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - //java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_ServiceHandle"); - cachedSerQNames.add(qName); - cls = ext.vamsas.ServiceHandle[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("registry.objects.vamsas", "ServiceHandles"); - cachedSerQNames.add(qName); - cls = ext.vamsas.ServiceHandles.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("registry.objects.vamsas", "ServiceHandle"); - cachedSerQNames.add(qName); - cls = ext.vamsas.ServiceHandle.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - + } + + public ext.vamsas.ServiceHandles getServices() + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); } - - protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { - try { - org.apache.axis.client.Call _call = - (org.apache.axis.client.Call) super.service.createCall(); - if (super.maintainSessionSet) { - _call.setMaintainSession(super.maintainSession); - } - if (super.cachedUsername != null) { - _call.setUsername(super.cachedUsername); - } - if (super.cachedPassword != null) { - _call.setPassword(super.cachedPassword); - } - if (super.cachedEndpoint != null) { - _call.setTargetEndpointAddress(super.cachedEndpoint); - } - if (super.cachedTimeout != null) { - _call.setTimeout(super.cachedTimeout); - } - if (super.cachedPortName != null) { - _call.setPortName(super.cachedPortName); - } - java.util.Enumeration keys = super.cachedProperties.keys(); - while (keys.hasMoreElements()) { - java.lang.String key = (java.lang.String) keys.nextElement(); - _call.setProperty(key, super.cachedProperties.get(key)); - } - // All the type mapping information is registered - // when the first call is made. - // The type mapping information is actually registered in - // the TypeMappingRegistry of the service, which - // is the reason why registration is only needed for the first call. - synchronized (this) { - if (firstCall()) { - // must set encoding style before registering serializers - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); - for (int i = 0; i < cachedSerFactories.size(); ++i) { - java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = - (javax.xml.namespace.QName) cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) - cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) - cachedDeserFactories.get(i); - _call.registerTypeMapping(cls, qName, sf, df, false); - } - } - } - return _call; - } - catch (java.lang.Throwable _t) { - throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); - } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getServices")); + + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {}); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; } - - public ext.vamsas.ServiceHandles getServices() throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[0]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getServices")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (ext.vamsas.ServiceHandles) _resp; - } catch (java.lang.Exception _exception) { - return (ext.vamsas.ServiceHandles) org.apache.axis.utils.JavaUtils.convert(_resp, ext.vamsas.ServiceHandles.class); - } - } + else + { + extractAttachments(_call); + try + { + return (ext.vamsas.ServiceHandles) _resp; + } + catch (java.lang.Exception _exception) + { + return (ext.vamsas.ServiceHandles) org.apache.axis.utils.JavaUtils. + convert(_resp, ext.vamsas.ServiceHandles.class); + } } + } } diff --git a/src/ext/vamsas/ServiceHandle.java b/src/ext/vamsas/ServiceHandle.java index 2b662f7..994ea5c 100755 --- a/src/ext/vamsas/ServiceHandle.java +++ b/src/ext/vamsas/ServiceHandle.java @@ -7,214 +7,245 @@ package ext.vamsas; -public class ServiceHandle implements java.io.Serializable { - private java.lang.String abstractName; - private java.lang.String description; - private java.lang.String endpointURL; - private java.lang.String name; - - public ServiceHandle() { - } - - public ServiceHandle( - java.lang.String abstractName, - java.lang.String description, - java.lang.String endpointURL, - java.lang.String name) { - this.abstractName = abstractName; - this.description = description; - this.endpointURL = endpointURL; - this.name = name; - } - - - /** - * Gets the abstractName value for this ServiceHandle. - * - * @return abstractName - */ - public java.lang.String getAbstractName() { - return abstractName; - } - - - /** - * Sets the abstractName value for this ServiceHandle. - * - * @param abstractName - */ - public void setAbstractName(java.lang.String abstractName) { - this.abstractName = abstractName; - } - - - /** - * Gets the description value for this ServiceHandle. - * - * @return description - */ - public java.lang.String getDescription() { - return description; - } - - - /** - * Sets the description value for this ServiceHandle. - * - * @param description - */ - public void setDescription(java.lang.String description) { - this.description = description; - } - - - /** - * Gets the endpointURL value for this ServiceHandle. - * - * @return endpointURL - */ - public java.lang.String getEndpointURL() { - return endpointURL; - } - - - /** - * Sets the endpointURL value for this ServiceHandle. - * - * @param endpointURL - */ - public void setEndpointURL(java.lang.String endpointURL) { - this.endpointURL = endpointURL; - } - - - /** - * Gets the name value for this ServiceHandle. - * - * @return name - */ - public java.lang.String getName() { - return name; - } - - - /** - * Sets the name value for this ServiceHandle. - * - * @param name - */ - public void setName(java.lang.String name) { - this.name = name; - } - - private java.lang.Object __equalsCalc = null; - public synchronized boolean equals(java.lang.Object obj) { - if (!(obj instanceof ServiceHandle)) return false; - ServiceHandle other = (ServiceHandle) obj; - if (obj == null) return false; - if (this == obj) return true; - if (__equalsCalc != null) { - return (__equalsCalc == obj); - } - __equalsCalc = obj; - boolean _equals; - _equals = true && - ((this.abstractName==null && other.getAbstractName()==null) || - (this.abstractName!=null && - this.abstractName.equals(other.getAbstractName()))) && - ((this.description==null && other.getDescription()==null) || - (this.description!=null && - this.description.equals(other.getDescription()))) && - ((this.endpointURL==null && other.getEndpointURL()==null) || - (this.endpointURL!=null && - this.endpointURL.equals(other.getEndpointURL()))) && - ((this.name==null && other.getName()==null) || - (this.name!=null && - this.name.equals(other.getName()))); - __equalsCalc = null; - return _equals; - } - - private boolean __hashCodeCalc = false; - public synchronized int hashCode() { - if (__hashCodeCalc) { - return 0; - } - __hashCodeCalc = true; - int _hashCode = 1; - if (getAbstractName() != null) { - _hashCode += getAbstractName().hashCode(); - } - if (getDescription() != null) { - _hashCode += getDescription().hashCode(); - } - if (getEndpointURL() != null) { - _hashCode += getEndpointURL().hashCode(); - } - if (getName() != null) { - _hashCode += getName().hashCode(); - } - __hashCodeCalc = false; - return _hashCode; - } - - // Type metadata - private static org.apache.axis.description.TypeDesc typeDesc = - new org.apache.axis.description.TypeDesc(ServiceHandle.class, true); - - static { - typeDesc.setXmlType(new javax.xml.namespace.QName("registry.objects.vamsas", "ServiceHandle")); - org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("abstractName"); - elemField.setXmlName(new javax.xml.namespace.QName("", "abstractName")); - elemField.setXmlType(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("description"); - elemField.setXmlName(new javax.xml.namespace.QName("", "description")); - elemField.setXmlType(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("endpointURL"); - elemField.setXmlName(new javax.xml.namespace.QName("", "endpointURL")); - elemField.setXmlType(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("name"); - elemField.setXmlName(new javax.xml.namespace.QName("", "name")); - elemField.setXmlType(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "string")); - typeDesc.addFieldDesc(elemField); - } - - /** - * Return type metadata object - */ - public static org.apache.axis.description.TypeDesc getTypeDesc() { - return typeDesc; - } - - /** - * Get Custom Serializer - */ - public static org.apache.axis.encoding.Serializer getSerializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanSerializer( +public class ServiceHandle + implements java.io.Serializable +{ + private java.lang.String abstractName; + private java.lang.String description; + private java.lang.String endpointURL; + private java.lang.String name; + + public ServiceHandle() + { + } + + public ServiceHandle( + java.lang.String abstractName, + java.lang.String description, + java.lang.String endpointURL, + java.lang.String name) + { + this.abstractName = abstractName; + this.description = description; + this.endpointURL = endpointURL; + this.name = name; + } + + /** + * Gets the abstractName value for this ServiceHandle. + * + * @return abstractName + */ + public java.lang.String getAbstractName() + { + return abstractName; + } + + /** + * Sets the abstractName value for this ServiceHandle. + * + * @param abstractName + */ + public void setAbstractName(java.lang.String abstractName) + { + this.abstractName = abstractName; + } + + /** + * Gets the description value for this ServiceHandle. + * + * @return description + */ + public java.lang.String getDescription() + { + return description; + } + + /** + * Sets the description value for this ServiceHandle. + * + * @param description + */ + public void setDescription(java.lang.String description) + { + this.description = description; + } + + /** + * Gets the endpointURL value for this ServiceHandle. + * + * @return endpointURL + */ + public java.lang.String getEndpointURL() + { + return endpointURL; + } + + /** + * Sets the endpointURL value for this ServiceHandle. + * + * @param endpointURL + */ + public void setEndpointURL(java.lang.String endpointURL) + { + this.endpointURL = endpointURL; + } + + /** + * Gets the name value for this ServiceHandle. + * + * @return name + */ + public java.lang.String getName() + { + return name; + } + + /** + * Sets the name value for this ServiceHandle. + * + * @param name + */ + public void setName(java.lang.String name) + { + this.name = name; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) + { + if (! (obj instanceof ServiceHandle)) + { + return false; + } + ServiceHandle other = (ServiceHandle) obj; + if (obj == null) + { + return false; + } + if (this == obj) + { + return true; + } + if (__equalsCalc != null) + { + return (__equalsCalc == obj); + } + __equalsCalc = obj; + boolean _equals; + _equals = true && + ( (this.abstractName == null && other.getAbstractName() == null) || + (this.abstractName != null && + this.abstractName.equals(other.getAbstractName()))) && + ( (this.description == null && other.getDescription() == null) || + (this.description != null && + this.description.equals(other.getDescription()))) && + ( (this.endpointURL == null && other.getEndpointURL() == null) || + (this.endpointURL != null && + this.endpointURL.equals(other.getEndpointURL()))) && + ( (this.name == null && other.getName() == null) || + (this.name != null && + this.name.equals(other.getName()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() + { + if (__hashCodeCalc) + { + return 0; + } + __hashCodeCalc = true; + int _hashCode = 1; + if (getAbstractName() != null) + { + _hashCode += getAbstractName().hashCode(); + } + if (getDescription() != null) + { + _hashCode += getDescription().hashCode(); + } + if (getEndpointURL() != null) + { + _hashCode += getEndpointURL().hashCode(); + } + if (getName() != null) + { + _hashCode += getName().hashCode(); + } + __hashCodeCalc = false; + return _hashCode; + } + + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = + new org.apache.axis.description.TypeDesc(ServiceHandle.class, true); + + static + { + typeDesc.setXmlType(new javax.xml.namespace.QName("registry.objects.vamsas", + "ServiceHandle")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis. + description.ElementDesc(); + elemField.setFieldName("abstractName"); + elemField.setXmlName(new javax.xml.namespace.QName("", "abstractName")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://schemas.xmlsoap.org/soap/encoding/", "string")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("description"); + elemField.setXmlName(new javax.xml.namespace.QName("", "description")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://schemas.xmlsoap.org/soap/encoding/", "string")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("endpointURL"); + elemField.setXmlName(new javax.xml.namespace.QName("", "endpointURL")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://schemas.xmlsoap.org/soap/encoding/", "string")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("name"); + elemField.setXmlName(new javax.xml.namespace.QName("", "name")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://schemas.xmlsoap.org/soap/encoding/", "string")); + typeDesc.addFieldDesc(elemField); + } + + /** + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() + { + return typeDesc; + } + + /** + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) + { + return + new org.apache.axis.encoding.ser.BeanSerializer( _javaType, _xmlType, typeDesc); - } - - /** - * Get Custom Deserializer - */ - public static org.apache.axis.encoding.Deserializer getDeserializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanDeserializer( + } + + /** + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, + java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) + { + return + new org.apache.axis.encoding.ser.BeanDeserializer( _javaType, _xmlType, typeDesc); - } + } } diff --git a/src/ext/vamsas/ServiceHandles.java b/src/ext/vamsas/ServiceHandles.java index 1c4932f..1de1345 100755 --- a/src/ext/vamsas/ServiceHandles.java +++ b/src/ext/vamsas/ServiceHandles.java @@ -7,120 +7,147 @@ package ext.vamsas; -public class ServiceHandles implements java.io.Serializable { - private ext.vamsas.ServiceHandle[] services; - - public ServiceHandles() { +public class ServiceHandles + implements java.io.Serializable +{ + private ext.vamsas.ServiceHandle[] services; + + public ServiceHandles() + { + } + + public ServiceHandles( + ext.vamsas.ServiceHandle[] services) + { + this.services = services; + } + + /** + * Gets the services value for this ServiceHandles. + * + * @return services + */ + public ext.vamsas.ServiceHandle[] getServices() + { + return services; + } + + /** + * Sets the services value for this ServiceHandles. + * + * @param services + */ + public void setServices(ext.vamsas.ServiceHandle[] services) + { + this.services = services; + } + + private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) + { + if (! (obj instanceof ServiceHandles)) + { + return false; } - - public ServiceHandles( - ext.vamsas.ServiceHandle[] services) { - this.services = services; + ServiceHandles other = (ServiceHandles) obj; + if (obj == null) + { + return false; } - - - /** - * Gets the services value for this ServiceHandles. - * - * @return services - */ - public ext.vamsas.ServiceHandle[] getServices() { - return services; + if (this == obj) + { + return true; } - - - /** - * Sets the services value for this ServiceHandles. - * - * @param services - */ - public void setServices(ext.vamsas.ServiceHandle[] services) { - this.services = services; + if (__equalsCalc != null) + { + return (__equalsCalc == obj); } - - private java.lang.Object __equalsCalc = null; - public synchronized boolean equals(java.lang.Object obj) { - if (!(obj instanceof ServiceHandles)) return false; - ServiceHandles other = (ServiceHandles) obj; - if (obj == null) return false; - if (this == obj) return true; - if (__equalsCalc != null) { - return (__equalsCalc == obj); - } - __equalsCalc = obj; - boolean _equals; - _equals = true && - ((this.services==null && other.getServices()==null) || - (this.services!=null && - java.util.Arrays.equals(this.services, other.getServices()))); - __equalsCalc = null; - return _equals; + __equalsCalc = obj; + boolean _equals; + _equals = true && + ( (this.services == null && other.getServices() == null) || + (this.services != null && + java.util.Arrays.equals(this.services, other.getServices()))); + __equalsCalc = null; + return _equals; + } + + private boolean __hashCodeCalc = false; + public synchronized int hashCode() + { + if (__hashCodeCalc) + { + return 0; } - - private boolean __hashCodeCalc = false; - public synchronized int hashCode() { - if (__hashCodeCalc) { - return 0; - } - __hashCodeCalc = true; - int _hashCode = 1; - if (getServices() != null) { - for (int i=0; - iwidth) - width = seqs[i].getLength(); - } - - Hashtable [] reply = new Hashtable[width]; - - if(end>=width) - { - end = width; - } - - calculate(seqs, start, end, reply); - - return reply; - } - -public static final void calculate(SequenceI[] sequences, - int start, int end, - Hashtable [] result) -{ - Hashtable residueHash; - int maxCount, nongap, i, j, v, jSize = sequences.length; - String maxResidue; - char c; - float percentage; + public static final String PID_NOGAPS = "N"; - int[] values = new int[255]; + public static final Hashtable[] calculate(Vector sequences, int start, + int end) + { + SequenceI[] seqs = new SequenceI[sequences.size()]; + int width = 0; + for (int i = 0; i < sequences.size(); i++) + { + seqs[i] = (SequenceI) sequences.elementAt(i); + if (seqs[i].getLength() > width) + { + width = seqs[i].getLength(); + } + } - char [] seq; + Hashtable[] reply = new Hashtable[width]; - for (i = start; i < end; i++) + if (end >= width) + { + end = width; + } + + calculate(seqs, start, end, reply); + + return reply; + } + + public static final void calculate(SequenceI[] sequences, + int start, int end, + Hashtable[] result) { - residueHash = new Hashtable(); - maxCount = 0; - maxResidue = ""; - nongap = 0; - values = new int[255]; + Hashtable residueHash; + int maxCount, nongap, i, j, v, jSize = sequences.length; + String maxResidue; + char c; + float percentage; + + int[] values = new int[255]; + + char[] seq; - for (j = 0; j < jSize; j++) + for (i = start; i < end; i++) { - seq = sequences[j].getSequence(); - if (seq.length > i) - { - c = seq[i]; + residueHash = new Hashtable(); + maxCount = 0; + maxResidue = ""; + nongap = 0; + values = new int[255]; - if(c == '.' || c==' ') - c = '-'; + for (j = 0; j < jSize; j++) + { + seq = sequences[j].getSequence(); + if (seq.length > i) + { + c = seq[i]; + + if (c == '.' || c == ' ') + { + c = '-'; + } + + if (c == '-') + { + values['-']++; + continue; + } + else if ('a' <= c && c <= 'z') + { + c -= 32; //('a' - 'A'); + } + + nongap++; + values[c]++; - if(c=='-') + } + else { values['-']++; - continue; } - else if ('a' <= c && c <= 'z') + } + + for (v = 'A'; v < 'Z'; v++) + { + if (values[v] < 2 || values[v] < maxCount) { - c -= 32 ;//('a' - 'A'); + continue; } - nongap++; - values[c]++; - - } - else - { - values['-']++; + if (values[v] > maxCount) + { + maxResidue = String.valueOf( (char) v); + } + else if (values[v] == maxCount) + { + maxResidue += String.valueOf( (char) v); + } + maxCount = values[v]; } - } - - for (v = 'A'; v < 'Z'; v++) - { - if (values[v] < 2 || values[v] < maxCount) - continue; - if (values[v] > maxCount) + if (maxResidue.length() == 0) { - maxResidue = String.valueOf( (char) v); + maxResidue = "-"; } - else if (values[v] == maxCount) - { - maxResidue += String.valueOf( (char) v); - } - maxCount = values[v]; - } - if(maxResidue.length()==0) - maxResidue = "-"; + residueHash.put(MAXCOUNT, new Integer(maxCount)); + residueHash.put(MAXRESIDUE, maxResidue); - residueHash.put(MAXCOUNT, new Integer(maxCount)); - residueHash.put(MAXRESIDUE, maxResidue); + percentage = ( (float) maxCount * 100) / (float) jSize; + residueHash.put(PID_GAPS, new Float(percentage)); - percentage = ( (float) maxCount * 100) / (float) jSize; - residueHash.put(PID_GAPS, new Float(percentage)); - - percentage = ( (float) maxCount * 100) / (float) nongap; - residueHash.put(PID_NOGAPS, new Float(percentage)); - result[i] = residueHash; + percentage = ( (float) maxCount * 100) / (float) nongap; + residueHash.put(PID_NOGAPS, new Float(percentage)); + result[i] = residueHash; + } } } -} - - diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index db549a4..2fcc593 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -1,33 +1,30 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.analysis; -import jalview.datamodel.SequenceI; - -import jalview.schemes.*; - -import jalview.util.*; +import java.util.*; import java.awt.*; -import java.util.*; - +import jalview.datamodel.*; +import jalview.schemes.*; +import jalview.util.*; /** * @@ -37,841 +34,853 @@ import java.util.*; */ public class AlignSeq { - public static final String PEP = "pep"; - public static final String DNA = "dna"; - /** DOCUMENT ME!! */ - public static java.util.Hashtable dnaHash = new java.util.Hashtable(); - - static - { - dnaHash.put("C", new Integer(0)); - dnaHash.put("T", new Integer(1)); - dnaHash.put("A", new Integer(2)); - dnaHash.put("G", new Integer(3)); - dnaHash.put("-", new Integer(4)); - } - - static String[] dna = { "C", "T", "A", "G", "-" }; - static String[] pep = - { - "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", - "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-" - }; - int[][] score; - int[][] E; - int[][] F; - int[][] traceback; - int[] seq1; - int[] seq2; - SequenceI s1; - SequenceI s2; - public String s1str; - public String s2str; - int maxi; - int maxj; - int[] aseq1; - int[] aseq2; - public String astr1=""; - public String astr2=""; - - /** DOCUMENT ME!! */ - public int seq1start; - - /** DOCUMENT ME!! */ - public int seq1end; - - /** DOCUMENT ME!! */ - public int seq2start; - - /** DOCUMENT ME!! */ - public int seq2end; - int count; - - /** DOCUMENT ME!! */ - public int maxscore; - float pid; - int prev = 0; - int gapOpen = 120; - int gapExtend = 20; - int[][] lookup = ResidueProperties.getBLOSUM62(); - String[] intToStr = pep; - int defInt = 23; - StringBuffer output = new StringBuffer(); - String type; - - /** - * Creates a new AlignSeq object. - * - * @param s1 DOCUMENT ME! - * @param s2 DOCUMENT ME! - * @param type DOCUMENT ME! - */ - public AlignSeq(SequenceI s1, SequenceI s2, String type) - { - SeqInit(s1, s1.getSequenceAsString(), s2, s2.getSequenceAsString(), type); - } - - /** - * Creates a new AlignSeq object. - * - * @param s1 DOCUMENT ME! - * @param s2 DOCUMENT ME! - * @param type DOCUMENT ME! - */ - public AlignSeq(SequenceI s1, - String string1, - SequenceI s2, - String string2, - String type) + public static final String PEP = "pep"; + public static final String DNA = "dna"; + /** DOCUMENT ME!! */ + public static java.util.Hashtable dnaHash = new java.util.Hashtable(); + + static + { + dnaHash.put("C", new Integer(0)); + dnaHash.put("T", new Integer(1)); + dnaHash.put("A", new Integer(2)); + dnaHash.put("G", new Integer(3)); + dnaHash.put("-", new Integer(4)); + } + + static String[] dna = + { + "C", "T", "A", "G", "-"}; + static String[] pep = + { + "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", + "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-" + }; + int[][] score; + int[][] E; + int[][] F; + int[][] traceback; + int[] seq1; + int[] seq2; + SequenceI s1; + SequenceI s2; + public String s1str; + public String s2str; + int maxi; + int maxj; + int[] aseq1; + int[] aseq2; + public String astr1 = ""; + public String astr2 = ""; + + /** DOCUMENT ME!! */ + public int seq1start; + + /** DOCUMENT ME!! */ + public int seq1end; + + /** DOCUMENT ME!! */ + public int seq2start; + + /** DOCUMENT ME!! */ + public int seq2end; + int count; + + /** DOCUMENT ME!! */ + public int maxscore; + float pid; + int prev = 0; + int gapOpen = 120; + int gapExtend = 20; + int[][] lookup = ResidueProperties.getBLOSUM62(); + String[] intToStr = pep; + int defInt = 23; + StringBuffer output = new StringBuffer(); + String type; + + /** + * Creates a new AlignSeq object. + * + * @param s1 DOCUMENT ME! + * @param s2 DOCUMENT ME! + * @param type DOCUMENT ME! + */ + public AlignSeq(SequenceI s1, SequenceI s2, String type) + { + SeqInit(s1, s1.getSequenceAsString(), s2, s2.getSequenceAsString(), type); + } + + /** + * Creates a new AlignSeq object. + * + * @param s1 DOCUMENT ME! + * @param s2 DOCUMENT ME! + * @param type DOCUMENT ME! + */ + public AlignSeq(SequenceI s1, + String string1, + SequenceI s2, + String string2, + String type) + { + SeqInit(s1, string1, s2, string2, type); + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getMaxScore() + { + return maxscore; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSeq2Start() + { + return seq2start; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSeq2End() + { + return seq2end; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSeq1Start() + { + return seq1start; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSeq1End() + { + return seq1end; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getOutput() + { + return output.toString(); + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getAStr1() + { + return astr1; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getAStr2() + { + return astr2; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int[] getASeq1() + { + return aseq1; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int[] getASeq2() + { + return aseq2; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceI getS1() + { + return s1; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceI getS2() + { + return s2; + } + + /** + * DOCUMENT ME! + * + * @param s1 DOCUMENT ME! + * @param string1 - string to align for sequence1 + * @param s2 sequence 2 + * @param string2 - string to align for sequence2 + * @param type DNA or PEPTIDE + */ + public void SeqInit(SequenceI s1, + String string1, + SequenceI s2, + String string2, + String type) + { + this.s1 = s1; + this.s2 = s2; + setDefaultParams(type); + SeqInit(string1, string2); + } + + public void SeqInit(SequenceI s1, + String string1, + SequenceI s2, + String string2, + ScoreMatrix scoreMatrix) + { + this.s1 = s1; + this.s2 = s2; + setType(scoreMatrix.isDNA() ? AlignSeq.DNA : AlignSeq.PEP); + lookup = scoreMatrix.getMatrix(); + } + + /** + * construct score matrix for string1 and string2 (after removing any existing gaps + * @param string1 + * @param string2 + */ + private void SeqInit(String string1, String string2) + { + s1str = extractGaps(jalview.util.Comparison.GapChars, string1); + s2str = extractGaps(jalview.util.Comparison.GapChars, string2); + + if (s1str.length() == 0 || s2str.length() == 0) { - SeqInit(s1, string1, s2, string2, type); + output.append("ALL GAPS: " + + (s1str.length() == 0 ? s1.getName() : " ") + + (s2str.length() == 0 ? s2.getName() : "")); + return; } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getMaxScore() + //System.out.println("lookuip " + rt.freeMemory() + " "+ rt.totalMemory()); + seq1 = new int[s1str.length()]; + + //System.out.println("seq1 " + rt.freeMemory() +" " + rt.totalMemory()); + seq2 = new int[s2str.length()]; + + //System.out.println("seq2 " + rt.freeMemory() + " " + rt.totalMemory()); + score = new int[s1str.length()][s2str.length()]; + + //System.out.println("score " + rt.freeMemory() + " " + rt.totalMemory()); + E = new int[s1str.length()][s2str.length()]; + + //System.out.println("E " + rt.freeMemory() + " " + rt.totalMemory()); + F = new int[s1str.length()][s2str.length()]; + traceback = new int[s1str.length()][s2str.length()]; + + //System.out.println("F " + rt.freeMemory() + " " + rt.totalMemory()); + seq1 = stringToInt(s1str, type); + + //System.out.println("seq1 " + rt.freeMemory() + " " + rt.totalMemory()); + seq2 = stringToInt(s2str, type); + + //System.out.println("Seq2 " + rt.freeMemory() + " " + rt.totalMemory()); + // long tstart = System.currentTimeMillis(); + // calcScoreMatrix(); + //long tend = System.currentTimeMillis(); + //System.out.println("Time take to calculate score matrix = " + (tend-tstart) + " ms"); + // printScoreMatrix(score); + //System.out.println(); + //printScoreMatrix(traceback); + //System.out.println(); + // printScoreMatrix(E); + //System.out.println(); + ///printScoreMatrix(F); + //System.out.println(); + // tstart = System.currentTimeMillis(); + //traceAlignment(); + //tend = System.currentTimeMillis(); + //System.out.println("Time take to traceback alignment = " + (tend-tstart) + " ms"); + } + + private void setDefaultParams(String type) + { + setType(type); + + if (type.equals(AlignSeq.PEP)) { - return maxscore; + lookup = ResidueProperties.getDefaultPeptideMatrix(); } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getSeq2Start() + else if (type.equals(AlignSeq.DNA)) { - return seq2start; + lookup = ResidueProperties.getDefaultDnaMatrix(); } + } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getSeq2End() + private void setType(String type2) + { + this.type = type2; + if (type.equals(AlignSeq.PEP)) { - return seq2end; + intToStr = pep; + defInt = 23; } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getSeq1Start() + else if (type.equals(AlignSeq.DNA)) { - return seq1start; + intToStr = dna; + defInt = 4; } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getSeq1End() + else { - return seq1end; + output.append("Wrong type = dna or pep only"); + throw new Error("Unknown Type " + type2 + + " - dna or pep are the only allowed values."); } + } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String getOutput() - { - return output.toString(); - } + /** + * DOCUMENT ME! + */ + public void traceAlignment() + { + // Find the maximum score along the rhs or bottom row + int max = -9999; - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String getAStr1() + for (int i = 0; i < seq1.length; i++) { - return astr1; + if (score[i][seq2.length - 1] > max) + { + max = score[i][seq2.length - 1]; + maxi = i; + maxj = seq2.length - 1; + } } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String getAStr2() + for (int j = 0; j < seq2.length; j++) { - return astr2; + if (score[seq1.length - 1][j] > max) + { + max = score[seq1.length - 1][j]; + maxi = seq1.length - 1; + maxj = j; + } } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int[] getASeq1() - { - return aseq1; - } + // System.out.println(maxi + " " + maxj + " " + score[maxi][maxj]); + int i = maxi; + int j = maxj; + int trace; + maxscore = score[i][j] / 10; - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int[] getASeq2() - { - return aseq2; - } + seq1end = maxi + 1; + seq2end = maxj + 1; - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public SequenceI getS1() - { - return s1; - } + aseq1 = new int[seq1.length + seq2.length]; + aseq2 = new int[seq1.length + seq2.length]; - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public SequenceI getS2() - { - return s2; - } + count = (seq1.length + seq2.length) - 1; - /** - * DOCUMENT ME! - * - * @param s1 DOCUMENT ME! - * @param string1 - string to align for sequence1 - * @param s2 sequence 2 - * @param string2 - string to align for sequence2 - * @param type DNA or PEPTIDE - */ - public void SeqInit(SequenceI s1, - String string1, - SequenceI s2, - String string2, - String type) + while ( (i > 0) && (j > 0)) { - this.s1 = s1; - this.s2 = s2; - setDefaultParams(type); - SeqInit(string1,string2); - } - public void SeqInit(SequenceI s1, - String string1, - SequenceI s2, - String string2, - ScoreMatrix scoreMatrix) { - this.s1=s1; - this.s2=s2; - setType(scoreMatrix.isDNA() ? AlignSeq.DNA : AlignSeq.PEP); - lookup=scoreMatrix.getMatrix(); - } - /** - * construct score matrix for string1 and string2 (after removing any existing gaps - * @param string1 - * @param string2 - */ - private void SeqInit(String string1, String string2) { - s1str = extractGaps(jalview.util.Comparison.GapChars, string1); - s2str = extractGaps(jalview.util.Comparison.GapChars, string2); - - if(s1str.length()==0 || s2str.length()==0) + if ( (aseq1[count] != defInt) && (i >= 0)) { - output.append("ALL GAPS: " + - (s1str.length()==0?s1.getName():" ") - +(s2str.length()==0?s2.getName():"")); - return; + aseq1[count] = seq1[i]; + astr1 = intToStr[seq1[i]] + astr1; } - //System.out.println("lookuip " + rt.freeMemory() + " "+ rt.totalMemory()); - seq1 = new int[s1str.length()]; - - //System.out.println("seq1 " + rt.freeMemory() +" " + rt.totalMemory()); - seq2 = new int[s2str.length()]; - - //System.out.println("seq2 " + rt.freeMemory() + " " + rt.totalMemory()); - score = new int[s1str.length()][s2str.length()]; - - //System.out.println("score " + rt.freeMemory() + " " + rt.totalMemory()); - E = new int[s1str.length()][s2str.length()]; - - //System.out.println("E " + rt.freeMemory() + " " + rt.totalMemory()); - F = new int[s1str.length()][s2str.length()]; - traceback = new int[s1str.length()][s2str.length()]; - - //System.out.println("F " + rt.freeMemory() + " " + rt.totalMemory()); - seq1 = stringToInt(s1str, type); - - //System.out.println("seq1 " + rt.freeMemory() + " " + rt.totalMemory()); - seq2 = stringToInt(s2str, type); - - //System.out.println("Seq2 " + rt.freeMemory() + " " + rt.totalMemory()); - // long tstart = System.currentTimeMillis(); - // calcScoreMatrix(); - //long tend = System.currentTimeMillis(); - //System.out.println("Time take to calculate score matrix = " + (tend-tstart) + " ms"); - // printScoreMatrix(score); - //System.out.println(); - //printScoreMatrix(traceback); - //System.out.println(); - // printScoreMatrix(E); - //System.out.println(); - ///printScoreMatrix(F); - //System.out.println(); - // tstart = System.currentTimeMillis(); - //traceAlignment(); - //tend = System.currentTimeMillis(); - //System.out.println("Time take to traceback alignment = " + (tend-tstart) + " ms"); - } + if ( (aseq2[count] != defInt) && (j > 0)) + { + aseq2[count] = seq2[j]; + astr2 = intToStr[seq2[j]] + astr2; + } - private void setDefaultParams(String type) { - setType(type); - - if (type.equals(AlignSeq.PEP)) - { - lookup = ResidueProperties.getDefaultPeptideMatrix(); - } - else if (type.equals(AlignSeq.DNA)) - { - lookup = ResidueProperties.getDefaultDnaMatrix(); - } - } + trace = findTrace(i, j); - private void setType(String type2) { - this.type = type2; - if (type.equals(AlignSeq.PEP)) + if (trace == 0) { - intToStr = pep; - defInt = 23; + i--; + j--; } - else if (type.equals(AlignSeq.DNA)) + else if (trace == 1) { - intToStr = dna; - defInt = 4; + j--; + aseq1[count] = defInt; + astr1 = "-" + astr1.substring(1); } - else + else if (trace == -1) { - output.append("Wrong type = dna or pep only"); - throw new Error("Unknown Type "+type2+" - dna or pep are the only allowed values."); + i--; + aseq2[count] = defInt; + astr2 = "-" + astr2.substring(1); } - } - /** - * DOCUMENT ME! - */ - public void traceAlignment() - { - // Find the maximum score along the rhs or bottom row - int max = -9999; + count--; + } - for (int i = 0; i < seq1.length; i++) - { - if (score[i][seq2.length - 1] > max) - { - max = score[i][seq2.length - 1]; - maxi = i; - maxj = seq2.length - 1; - } - } + seq1start = i + 1; + seq2start = j + 1; - for (int j = 0; j < seq2.length; j++) - { - if (score[seq1.length - 1][j] > max) - { - max = score[seq1.length - 1][j]; - maxi = seq1.length - 1; - maxj = j; - } - } + if (aseq1[count] != defInt) + { + aseq1[count] = seq1[i]; + astr1 = intToStr[seq1[i]] + astr1; + } - // System.out.println(maxi + " " + maxj + " " + score[maxi][maxj]); - int i = maxi; - int j = maxj; - int trace; - maxscore = score[i][j] / 10; + if (aseq2[count] != defInt) + { + aseq2[count] = seq2[j]; + astr2 = intToStr[seq2[j]] + astr2; + } + } - seq1end = maxi + 1; - seq2end = maxj + 1; + /** + * DOCUMENT ME! + */ + public void printAlignment(java.io.PrintStream os) + { + // Find the biggest id length for formatting purposes + int maxid = s1.getName().length(); - aseq1 = new int[seq1.length + seq2.length]; - aseq2 = new int[seq1.length + seq2.length]; + if (s2.getName().length() > maxid) + { + maxid = s2.getName().length(); + } - count = (seq1.length + seq2.length) - 1; + int len = 72 - maxid - 1; + int nochunks = ( (aseq1.length - count) / len) + 1; + pid = 0; + + output.append("Score = " + score[maxi][maxj] + "\n"); + output.append("Length of alignment = " + (aseq1.length - count) + "\n"); + output.append("Sequence "); + output.append(new Format("%" + maxid + "s").form(s1.getName())); + output.append(" : " + s1.getStart() + " - " + s1.getEnd() + + " (Sequence length = " + + s1str.length() + ")\n"); + output.append("Sequence "); + output.append(new Format("%" + maxid + "s").form(s2.getName())); + output.append(" : " + s2.getStart() + " - " + s2.getEnd() + + " (Sequence length = " + + s2str.length() + ")\n\n"); + + for (int j = 0; j < nochunks; j++) + { + // Print the first aligned sequence + output.append(new Format("%" + (maxid) + "s").form(s1.getName()) + " "); - while ((i > 0) && (j > 0)) + for (int i = 0; i < len; i++) + { + if ( (count + i + (j * len)) < aseq1.length) { - if ((aseq1[count] != defInt) && (i >= 0)) - { - aseq1[count] = seq1[i]; - astr1 = intToStr[seq1[i]] + astr1; - } - - if ((aseq2[count] != defInt) && (j > 0)) - { - aseq2[count] = seq2[j]; - astr2 = intToStr[seq2[j]] + astr2; - } + output.append(new Format("%s").form(intToStr[aseq1[count + i + + (j * len)]])); + } + } - trace = findTrace(i, j); + output.append("\n"); + output.append(new Format("%" + (maxid) + "s").form(" ") + " "); - if (trace == 0) - { - i--; - j--; - } - else if (trace == 1) + // Print out the matching chars + for (int i = 0; i < len; i++) + { + if ( (count + i + (j * len)) < aseq1.length) + { + if (intToStr[aseq1[count + i + (j * len)]].equals( + intToStr[aseq2[count + i + (j * len)]]) && + !intToStr[aseq1[count + i + (j * len)]].equals("-")) + { + pid++; + output.append("|"); + } + else if (type.equals("pep")) + { + if (ResidueProperties.getPAM250( + intToStr[aseq1[count + i + (j * len)]], + intToStr[aseq2[count + i + (j * len)]]) > 0) { - j--; - aseq1[count] = defInt; - astr1 = "-" + astr1.substring(1); + output.append("."); } - else if (trace == -1) + else { - i--; - aseq2[count] = defInt; - astr2 = "-" + astr2.substring(1); + output.append(" "); } - - count--; + } + else + { + output.append(" "); + } } + } - seq1start = i + 1; - seq2start = j + 1; + // Now print the second aligned sequence + output = output.append("\n"); + output = output.append(new Format("%" + (maxid) + "s").form(s2.getName()) + + " "); - if (aseq1[count] != defInt) + for (int i = 0; i < len; i++) + { + if ( (count + i + (j * len)) < aseq1.length) { - aseq1[count] = seq1[i]; - astr1 = intToStr[seq1[i]] + astr1; + output.append(new Format("%s").form(intToStr[aseq2[count + i + + (j * len)]])); } + } - if (aseq2[count] != defInt) - { - aseq2[count] = seq2[j]; - astr2 = intToStr[seq2[j]] + astr2; - } + output = output.append("\n\n"); } - /** - * DOCUMENT ME! - */ - public void printAlignment(java.io.PrintStream os) + pid = pid / (float) (aseq1.length - count) * 100; + output = output.append(new Format("Percentage ID = %2.2f\n\n").form(pid)); + + try + { + os.print(output.toString()); + } + catch (Exception ex) + {} + } + + /** + * DOCUMENT ME! + * + * @param mat DOCUMENT ME! + */ + public void printScoreMatrix(int[][] mat) + { + int n = seq1.length; + int m = seq2.length; + + for (int i = 0; i < n; i++) { - // Find the biggest id length for formatting purposes - int maxid = s1.getName().length(); + // Print the top sequence + if (i == 0) + { + Format.print(System.out, "%8s", s2str.substring(0, 1)); - if (s2.getName().length() > maxid) + for (int jj = 1; jj < m; jj++) { - maxid = s2.getName().length(); + Format.print(System.out, "%5s", s2str.substring(jj, jj + 1)); } - int len = 72 - maxid - 1; - int nochunks = ((aseq1.length - count) / len) + 1; - pid = 0; - - output.append("Score = " + score[maxi][maxj] + "\n"); - output.append("Length of alignment = " + (aseq1.length - count) + "\n"); - output.append("Sequence "); - output.append(new Format("%" + maxid + "s").form(s1.getName())); - output.append(" : " + s1.getStart() + " - " + s1.getEnd() + " (Sequence length = " + - s1str.length() + ")\n"); - output .append("Sequence "); - output.append(new Format("%" + maxid + "s").form(s2.getName())); - output.append(" : " + s2.getStart() + " - " + s2.getEnd() + " (Sequence length = " + - s2str.length() + ")\n\n"); - - for (int j = 0; j < nochunks; j++) - { - // Print the first aligned sequence - output.append(new Format("%" + (maxid) + "s").form(s1.getName()) + " "); - - for (int i = 0; i < len; i++) - { - if ((count + i + (j * len)) < aseq1.length) - { - output.append(new Format("%s").form(intToStr[aseq1[count + i + - (j * len)]])); - } - } - - output.append("\n"); - output.append(new Format("%" + (maxid) + "s").form(" ") + " "); - - // Print out the matching chars - for (int i = 0; i < len; i++) - { - if ((count + i + (j * len)) < aseq1.length) - { - if (intToStr[aseq1[count + i + (j * len)]].equals( - intToStr[aseq2[count + i + (j * len)]]) && - !intToStr[aseq1[count + i + (j * len)]].equals("-")) - { - pid++; - output.append("|"); - } - else if (type.equals("pep")) - { - if (ResidueProperties.getPAM250( - intToStr[aseq1[count + i + (j * len)]], - intToStr[aseq2[count + i + (j * len)]]) > 0) - { - output.append("."); - } - else - { - output.append(" "); - } - } - else - { - output.append(" "); - } - } - } - - // Now print the second aligned sequence - output = output.append("\n"); - output = output.append(new Format("%" + (maxid) + "s").form(s2.getName()) + " "); - - for (int i = 0; i < len; i++) - { - if ((count + i + (j * len)) < aseq1.length) - { - output .append(new Format("%s").form(intToStr[aseq2[count + i + - (j * len)]])); - } - } + System.out.println(); + } - output = output .append("\n\n"); + for (int j = 0; j < m; j++) + { + if (j == 0) + { + Format.print(System.out, "%3s", s1str.substring(i, i + 1)); } - pid = pid / (float) (aseq1.length - count) * 100; - output = output.append(new Format("Percentage ID = %2.2f\n\n").form(pid)); + Format.print(System.out, "%3d ", mat[i][j] / 10); + } - try{ - os.print(output.toString()); - }catch(Exception ex){} + System.out.println(); } - - /** - * DOCUMENT ME! - * - * @param mat DOCUMENT ME! - */ - public void printScoreMatrix(int[][] mat) + } + + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int findTrace(int i, int j) + { + int t = 0; + int max = score[i - 1][j - 1] + (lookup[seq1[i]][seq2[j]] * 10); + + if (F[i][j] > max) { - int n = seq1.length; - int m = seq2.length; - - for (int i = 0; i < n; i++) - { - // Print the top sequence - if (i == 0) - { - Format.print(System.out, "%8s", s2str.substring(0, 1)); + max = F[i][j]; + t = -1; + } + else if (F[i][j] == max) + { + if (prev == -1) + { + max = F[i][j]; + t = -1; + } + } - for (int jj = 1; jj < m; jj++) - { - Format.print(System.out, "%5s", s2str.substring(jj, jj + 1)); - } + if (E[i][j] >= max) + { + max = E[i][j]; + t = 1; + } + else if (E[i][j] == max) + { + if (prev == 1) + { + max = E[i][j]; + t = 1; + } + } - System.out.println(); - } + prev = t; - for (int j = 0; j < m; j++) - { - if (j == 0) - { - Format.print(System.out, "%3s", s1str.substring(i, i + 1)); - } + return t; + } - Format.print(System.out, "%3d ", mat[i][j] / 10); - } + /** + * DOCUMENT ME! + */ + public void calcScoreMatrix() + { + int n = seq1.length; + int m = seq2.length; - System.out.println(); - } - } + // top left hand element + score[0][0] = lookup[seq1[0]][seq2[0]] * 10; + E[0][0] = -gapExtend; + F[0][0] = 0; - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - * @param j DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int findTrace(int i, int j) + // Calculate the top row first + for (int j = 1; j < m; j++) { - int t = 0; - int max = score[i - 1][j - 1] + (lookup[seq1[i]][seq2[j]] * 10); + // What should these values be? 0 maybe + E[0][j] = max(score[0][j - 1] - gapOpen, E[0][j - 1] - gapExtend); + F[0][j] = -gapExtend; - if (F[i][j] > max) - { - max = F[i][j]; - t = -1; - } - else if (F[i][j] == max) - { - if (prev == -1) - { - max = F[i][j]; - t = -1; - } - } + score[0][j] = max(lookup[seq1[0]][seq2[j]] * 10, -gapOpen, + -gapExtend); - if (E[i][j] >= max) - { - max = E[i][j]; - t = 1; - } - else if (E[i][j] == max) - { - if (prev == 1) - { - max = E[i][j]; - t = 1; - } - } + traceback[0][j] = 1; + } - prev = t; + // Now do the left hand column + for (int i = 1; i < n; i++) + { + E[i][0] = -gapOpen; + F[i][0] = max(score[i - 1][0] - gapOpen, F[i - 1][0] - gapExtend); - return t; + score[i][0] = max(lookup[seq1[i]][seq2[0]] * 10, E[i][0], F[i][0]); + traceback[i][0] = -1; } - /** - * DOCUMENT ME! - */ - public void calcScoreMatrix() + // Now do all the other rows + for (int i = 1; i < n; i++) + { + for (int j = 1; j < m; j++) + { + E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - + gapExtend); + F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - + gapExtend); + + score[i][j] = max(score[i - 1][j - 1] + + (lookup[seq1[i]][seq2[j]] * 10), E[i][j], F[i][j]); + traceback[i][j] = findTrace(i, j); + } + } + } + + /** + * DOCUMENT ME! + * + * @param gapChar DOCUMENT ME! + * @param seq DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String extractGaps(String gapChar, String seq) + { + StringTokenizer str = new StringTokenizer(seq, gapChar); + StringBuffer newString = new StringBuffer(); + + while (str.hasMoreTokens()) { - int n = seq1.length; - int m = seq2.length; + newString.append(str.nextToken()); + } - // top left hand element - score[0][0] = lookup[seq1[0]][seq2[0]] * 10; - E[0][0] = -gapExtend; - F[0][0] = 0; + return newString.toString(); + } + + /** + * DOCUMENT ME! + * + * @param i1 DOCUMENT ME! + * @param i2 DOCUMENT ME! + * @param i3 DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int max(int i1, int i2, int i3) + { + int max = i1; + + if (i2 > i1) + { + max = i2; + } - // Calculate the top row first - for (int j = 1; j < m; j++) - { - // What should these values be? 0 maybe - E[0][j] = max(score[0][j - 1] - gapOpen, E[0][j - 1] - gapExtend); - F[0][j] = -gapExtend; + if (i3 > max) + { + max = i3; + } - score[0][j] = max(lookup[seq1[0]][seq2[j]] * 10, -gapOpen, - -gapExtend); + return max; + } + + /** + * DOCUMENT ME! + * + * @param i1 DOCUMENT ME! + * @param i2 DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int max(int i1, int i2) + { + int max = i1; + + if (i2 > i1) + { + max = i2; + } - traceback[0][j] = 1; - } + return max; + } + + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int[] stringToInt(String s, String type) + { + int[] seq1 = new int[s.length()]; + + for (int i = 0; i < s.length(); i++) + { + // String ss = s.substring(i, i + 1).toUpperCase(); + char c = s.charAt(i); + if ('a' <= c && c <= 'z') + { + // TO UPPERCASE !!! + c -= ('a' - 'A'); + } - // Now do the left hand column - for (int i = 1; i < n; i++) + try + { + if (type.equals("pep")) { - E[i][0] = -gapOpen; - F[i][0] = max(score[i - 1][0] - gapOpen, F[i - 1][0] - gapExtend); - - score[i][0] = max(lookup[seq1[i]][seq2[0]] * 10, E[i][0], F[i][0]); - traceback[i][0] = -1; + seq1[i] = ResidueProperties.aaIndex[c]; } - - // Now do all the other rows - for (int i = 1; i < n; i++) + else if (type.equals("dna")) { - for (int j = 1; j < m; j++) - { - E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - - gapExtend); - F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - - gapExtend); - - score[i][j] = max(score[i - 1][j - 1] + - (lookup[seq1[i]][seq2[j]] * 10), E[i][j], F[i][j]); - traceback[i][j] = findTrace(i, j); - } + seq1[i] = ResidueProperties.nucleotideIndex[c]; } - } - - - /** - * DOCUMENT ME! - * - * @param gapChar DOCUMENT ME! - * @param seq DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public static String extractGaps(String gapChar, String seq) - { - StringTokenizer str = new StringTokenizer(seq, gapChar); - StringBuffer newString = new StringBuffer(); - - while (str.hasMoreTokens()) + if (seq1[i] > 23) { - newString.append( str.nextToken() ); + seq1[i] = 23; } - - return newString.toString(); - } - - /** - * DOCUMENT ME! - * - * @param i1 DOCUMENT ME! - * @param i2 DOCUMENT ME! - * @param i3 DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int max(int i1, int i2, int i3) - { - int max = i1; - - if (i2 > i1) + } + catch (Exception e) + { + if (type.equals("dna")) { - max = i2; + seq1[i] = 4; } - - if (i3 > max) + else { - max = i3; + seq1[i] = 23; } - - return max; + } } - /** - * DOCUMENT ME! - * - * @param i1 DOCUMENT ME! - * @param i2 DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int max(int i1, int i2) + return seq1; + } + + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param mat DOCUMENT ME! + * @param n DOCUMENT ME! + * @param m DOCUMENT ME! + * @param psize DOCUMENT ME! + */ + public static void displayMatrix(Graphics g, int[][] mat, int n, int m, + int psize) + { + int max = -1000; + int min = 1000; + + for (int i = 0; i < n; i++) { - int max = i1; - - if (i2 > i1) + for (int j = 0; j < m; j++) + { + if (mat[i][j] >= max) { - max = i2; + max = mat[i][j]; } - return max; - } - - /** - * DOCUMENT ME! - * - * @param s DOCUMENT ME! - * @param type DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int[] stringToInt(String s, String type) - { - int[] seq1 = new int[s.length()]; - - for (int i = 0; i < s.length(); i++) + if (mat[i][j] <= min) { - // String ss = s.substring(i, i + 1).toUpperCase(); - char c = s.charAt(i); - if ('a' <= c && c <= 'z') - { - // TO UPPERCASE !!! - c -= ('a' - 'A'); - } - - - try - { - if (type.equals("pep")) - { - seq1[i] = ResidueProperties.aaIndex[c]; - } - else if (type.equals("dna")) - { - seq1[i] = ResidueProperties.nucleotideIndex[c]; - } - - if (seq1[i] > 23) - { - seq1[i] = 23; - } - } - catch (Exception e) - { - if (type.equals("dna")) - { - seq1[i] = 4; - } - else - { - seq1[i] = 23; - } - } + min = mat[i][j]; } - - return seq1; + } } - /** - * DOCUMENT ME! - * - * @param g DOCUMENT ME! - * @param mat DOCUMENT ME! - * @param n DOCUMENT ME! - * @param m DOCUMENT ME! - * @param psize DOCUMENT ME! - */ - public static void displayMatrix(Graphics g, int[][] mat, int n, int m, - int psize) - { - int max = -1000; - int min = 1000; + System.out.println(max + " " + min); - for (int i = 0; i < n; i++) - { - for (int j = 0; j < m; j++) - { - if (mat[i][j] >= max) - { - max = mat[i][j]; - } - - if (mat[i][j] <= min) - { - min = mat[i][j]; - } - } - } - - System.out.println(max + " " + min); - - for (int i = 0; i < n; i++) - { - for (int j = 0; j < m; j++) - { - int x = psize * i; - int y = psize * j; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < m; j++) + { + int x = psize * i; + int y = psize * j; - // System.out.println(mat[i][j]); - float score = (float) (mat[i][j] - min) / (float) (max - min); - g.setColor(new Color(score, 0, 0)); - g.fillRect(x, y, psize, psize); + // System.out.println(mat[i][j]); + float score = (float) (mat[i][j] - min) / (float) (max - min); + g.setColor(new Color(score, 0, 0)); + g.fillRect(x, y, psize, psize); - // System.out.println(x + " " + y + " " + score); - } - } + // System.out.println(x + " " + y + " " + score); + } } + } } diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index 778142c..ea8d4e5 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -1,483 +1,486 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.analysis; -import jalview.datamodel.*; - -import jalview.util.*; - import java.util.*; +import jalview.datamodel.*; +import jalview.util.*; /** Data structure to hold and manipulate a multiple sequence alignment */ public class AlignmentSorter { - static boolean sortIdAscending = true; - static int lastGroupHash = 0; - static boolean sortGroupAscending = true; - static AlignmentOrder lastOrder = null; - static boolean sortOrderAscending = true; - static NJTree lastTree = null; - static boolean sortTreeAscending = true; - - /** - * Sort by Percentage Identity - * - * @param align AlignmentI - * @param s SequenceI - */ - public static void sortByPID(AlignmentI align, SequenceI s) - { - int nSeq = align.getHeight(); - - float[] scores = new float[nSeq]; - SequenceI[] seqs = new SequenceI[nSeq]; - - for (int i = 0; i < nSeq; i++) - { - scores[i] = Comparison.PID(align.getSequenceAt(i).getSequenceAsString(), - s.getSequenceAsString()); - seqs[i] = align.getSequenceAt(i); - } - - QuickSort.sort(scores, 0, scores.length - 1, seqs); - - setReverseOrder(align, seqs); + static boolean sortIdAscending = true; + static int lastGroupHash = 0; + static boolean sortGroupAscending = true; + static AlignmentOrder lastOrder = null; + static boolean sortOrderAscending = true; + static NJTree lastTree = null; + static boolean sortTreeAscending = true; + + /** + * Sort by Percentage Identity + * + * @param align AlignmentI + * @param s SequenceI + */ + public static void sortByPID(AlignmentI align, SequenceI s) + { + int nSeq = align.getHeight(); + + float[] scores = new float[nSeq]; + SequenceI[] seqs = new SequenceI[nSeq]; + + for (int i = 0; i < nSeq; i++) + { + scores[i] = Comparison.PID(align.getSequenceAt(i).getSequenceAsString(), + s.getSequenceAsString()); + seqs[i] = align.getSequenceAt(i); } - /** - * Reverse the order of the sort - * - * @param align DOCUMENT ME! - * @param seqs DOCUMENT ME! - */ - private static void setReverseOrder(AlignmentI align, SequenceI[] seqs) - { - int nSeq = seqs.length; + QuickSort.sort(scores, 0, scores.length - 1, seqs); - int len = 0; + setReverseOrder(align, seqs); + } - if ((nSeq % 2) == 0) - { - len = nSeq / 2; - } - else - { - len = (nSeq + 1) / 2; - } + /** + * Reverse the order of the sort + * + * @param align DOCUMENT ME! + * @param seqs DOCUMENT ME! + */ + private static void setReverseOrder(AlignmentI align, SequenceI[] seqs) + { + int nSeq = seqs.length; - // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work - for (int i = 0; i < len; i++) - { - //SequenceI tmp = seqs[i]; - align.getSequences().setElementAt(seqs[nSeq - i - 1], i); - align.getSequences().setElementAt(seqs[i], nSeq - i - 1); - } + int len = 0; + + if ( (nSeq % 2) == 0) + { + len = nSeq / 2; + } + else + { + len = (nSeq + 1) / 2; } - /** - * Sets the Alignment object with the given sequences - * - * @param align Alignment object to be updated - * @param tmp sequences as a vector - */ - private static void setOrder(AlignmentI align, Vector tmp) + // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work + for (int i = 0; i < len; i++) + { + //SequenceI tmp = seqs[i]; + align.getSequences().setElementAt(seqs[nSeq - i - 1], i); + align.getSequences().setElementAt(seqs[i], nSeq - i - 1); + } + } + + /** + * Sets the Alignment object with the given sequences + * + * @param align Alignment object to be updated + * @param tmp sequences as a vector + */ + private static void setOrder(AlignmentI align, Vector tmp) + { + setOrder(align, vectorSubsetToArray(tmp, align.getSequences())); + } + + /** + * Sets the Alignment object with the given sequences + * + * @param align DOCUMENT ME! + * @param seqs sequences as an array + */ + public static void setOrder(AlignmentI align, SequenceI[] seqs) + { + // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work + Vector algn = align.getSequences(); + Vector tmp = new Vector(); + + for (int i = 0; i < seqs.length; i++) { - setOrder(align, vectorSubsetToArray(tmp, align.getSequences())); + if (algn.contains(seqs[i])) + { + tmp.addElement(seqs[i]); + } } - /** - * Sets the Alignment object with the given sequences - * - * @param align DOCUMENT ME! - * @param seqs sequences as an array - */ - public static void setOrder(AlignmentI align, SequenceI[] seqs) + algn.removeAllElements(); + //User may have hidden seqs, then clicked undo or redo + for (int i = 0; i < tmp.size(); i++) { - // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work - Vector algn = align.getSequences(); - Vector tmp = new Vector(); + algn.addElement(tmp.elementAt(i)); + } - for (int i = 0; i < seqs.length; i++) - { - if(algn.contains(seqs[i])) - tmp.addElement(seqs[i]); - } + } - algn.removeAllElements(); - //User may have hidden seqs, then clicked undo or redo - for (int i = 0; i < tmp.size(); i++) - { - algn.addElement(tmp.elementAt(i)); - } + /** + * Sorts by ID. Numbers are sorted before letters. + * + * @param align The alignment object to sort + */ + public static void sortByID(AlignmentI align) + { + int nSeq = align.getHeight(); + String[] ids = new String[nSeq]; + SequenceI[] seqs = new SequenceI[nSeq]; + for (int i = 0; i < nSeq; i++) + { + ids[i] = align.getSequenceAt(i).getName(); + seqs[i] = align.getSequenceAt(i); + } + QuickSort.sort(ids, seqs); + if (sortIdAscending) + { + setReverseOrder(align, seqs); } - - /** - * Sorts by ID. Numbers are sorted before letters. - * - * @param align The alignment object to sort - */ - public static void sortByID(AlignmentI align) + else { - int nSeq = align.getHeight(); - - String[] ids = new String[nSeq]; - SequenceI[] seqs = new SequenceI[nSeq]; - - for (int i = 0; i < nSeq; i++) - { - ids[i] = align.getSequenceAt(i).getName(); - seqs[i] = align.getSequenceAt(i); - } - - QuickSort.sort(ids, seqs); - - if (sortIdAscending) - { - setReverseOrder(align, seqs); - } - else - { - setOrder(align, seqs); - } + setOrder(align, seqs); + } - sortIdAscending = !sortIdAscending; + sortIdAscending = !sortIdAscending; + } + + /** + * Sorts the alignment by size of group. + *
Maintains the order of sequences in each group + * by order in given alignment object. + * + * @param align sorts the given alignment object by group + */ + public static void sortByGroup(AlignmentI align) + { + //MAINTAINS ORIGNAL SEQUENCE ORDER, + //ORDERS BY GROUP SIZE + Vector groups = new Vector(); + + if (groups.hashCode() != lastGroupHash) + { + sortGroupAscending = true; + lastGroupHash = groups.hashCode(); + } + else + { + sortGroupAscending = !sortGroupAscending; } - /** - * Sorts the alignment by size of group. - *
Maintains the order of sequences in each group - * by order in given alignment object. - * - * @param align sorts the given alignment object by group - */ - public static void sortByGroup(AlignmentI align) + //SORTS GROUPS BY SIZE + ////////////////////// + for (int i = 0; i < align.getGroups().size(); i++) { - //MAINTAINS ORIGNAL SEQUENCE ORDER, - //ORDERS BY GROUP SIZE - Vector groups = new Vector(); + SequenceGroup sg = (SequenceGroup) align.getGroups().elementAt(i); - if (groups.hashCode() != lastGroupHash) - { - sortGroupAscending = true; - lastGroupHash = groups.hashCode(); - } - else - { - sortGroupAscending = !sortGroupAscending; - } + for (int j = 0; j < groups.size(); j++) + { + SequenceGroup sg2 = (SequenceGroup) groups.elementAt(j); - //SORTS GROUPS BY SIZE - ////////////////////// - for (int i = 0; i < align.getGroups().size(); i++) + if (sg.getSize() > sg2.getSize()) { - SequenceGroup sg = (SequenceGroup) align.getGroups().elementAt(i); - - for (int j = 0; j < groups.size(); j++) - { - SequenceGroup sg2 = (SequenceGroup) groups.elementAt(j); - - if (sg.getSize() > sg2.getSize()) - { - groups.insertElementAt(sg, j); + groups.insertElementAt(sg, j); - break; - } - } - - if (!groups.contains(sg)) - { - groups.addElement(sg); - } + break; } + } - //NOW ADD SEQUENCES MAINTAINING ALIGNMENT ORDER - /////////////////////////////////////////////// - Vector seqs = new Vector(); + if (!groups.contains(sg)) + { + groups.addElement(sg); + } + } - for (int i = 0; i < groups.size(); i++) - { - SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - SequenceI[] orderedseqs = sg.getSequencesInOrder(align); + //NOW ADD SEQUENCES MAINTAINING ALIGNMENT ORDER + /////////////////////////////////////////////// + Vector seqs = new Vector(); - for (int j = 0; j < orderedseqs.length; j++) - { - seqs.addElement(orderedseqs[j]); - } - } + for (int i = 0; i < groups.size(); i++) + { + SequenceGroup sg = (SequenceGroup) groups.elementAt(i); + SequenceI[] orderedseqs = sg.getSequencesInOrder(align); - if (sortGroupAscending) - { - setOrder(align, seqs); - } - else - { - setReverseOrder(align, - vectorSubsetToArray(seqs, align.getSequences())); - } + for (int j = 0; j < orderedseqs.length; j++) + { + seqs.addElement(orderedseqs[j]); + } } - /** - * Converts Vector to array. - * java 1.18 does not have Vector.toArray() - * - * @param tmp Vector of SequenceI objects - * - * @return array of Sequence[] - */ - private static SequenceI[] vectorToArray(Vector tmp) + if (sortGroupAscending) { - SequenceI[] seqs = new SequenceI[tmp.size()]; - - for (int i = 0; i < tmp.size(); i++) - { - seqs[i] = (SequenceI) tmp.elementAt(i); - } - - return seqs; + setOrder(align, seqs); } - - /** - * DOCUMENT ME! - * - * @param tmp DOCUMENT ME! - * @param mask DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - private static SequenceI[] vectorSubsetToArray(Vector tmp, Vector mask) + else { - Vector seqs = new Vector(); - int i; - boolean[] tmask = new boolean[mask.size()]; - - for (i = 0; i < mask.size(); i++) - tmask[i] = true; - - for (i = 0; i < tmp.size(); i++) - { - Object sq = tmp.elementAt(i); + setReverseOrder(align, + vectorSubsetToArray(seqs, align.getSequences())); + } + } + + /** + * Converts Vector to array. + * java 1.18 does not have Vector.toArray() + * + * @param tmp Vector of SequenceI objects + * + * @return array of Sequence[] + */ + private static SequenceI[] vectorToArray(Vector tmp) + { + SequenceI[] seqs = new SequenceI[tmp.size()]; + + for (int i = 0; i < tmp.size(); i++) + { + seqs[i] = (SequenceI) tmp.elementAt(i); + } - if (mask.contains(sq) && tmask[mask.indexOf(sq)]) - { - tmask[mask.indexOf(sq)] = false; - seqs.addElement(sq); - } - } + return seqs; + } + + /** + * DOCUMENT ME! + * + * @param tmp DOCUMENT ME! + * @param mask DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private static SequenceI[] vectorSubsetToArray(Vector tmp, Vector mask) + { + Vector seqs = new Vector(); + int i; + boolean[] tmask = new boolean[mask.size()]; + + for (i = 0; i < mask.size(); i++) + { + tmask[i] = true; + } - for (i = 0; i < tmask.length; i++) - if (tmask[i]) - { - seqs.addElement(mask.elementAt(i)); - } + for (i = 0; i < tmp.size(); i++) + { + Object sq = tmp.elementAt(i); - return vectorToArray(seqs); + if (mask.contains(sq) && tmask[mask.indexOf(sq)]) + { + tmask[mask.indexOf(sq)] = false; + seqs.addElement(sq); + } } - /** - * Sorts by a given AlignmentOrder object - * - * @param align Alignment to order - * @param order specified order for alignment - */ - public static void sortBy(AlignmentI align, AlignmentOrder order) + for (i = 0; i < tmask.length; i++) { - // Get an ordered vector of sequences which may also be present in align - Vector tmp = order.getOrder(); - - if (lastOrder == order) - { - sortOrderAscending = !sortOrderAscending; - } - else - { - sortOrderAscending = true; - } + if (tmask[i]) + { + seqs.addElement(mask.elementAt(i)); + } + } - if (sortOrderAscending) - { - setOrder(align, tmp); - } - else - { - setReverseOrder(align, - vectorSubsetToArray(tmp, align.getSequences())); - } + return vectorToArray(seqs); + } + + /** + * Sorts by a given AlignmentOrder object + * + * @param align Alignment to order + * @param order specified order for alignment + */ + public static void sortBy(AlignmentI align, AlignmentOrder order) + { + // Get an ordered vector of sequences which may also be present in align + Vector tmp = order.getOrder(); + + if (lastOrder == order) + { + sortOrderAscending = !sortOrderAscending; + } + else + { + sortOrderAscending = true; } - /** - * DOCUMENT ME! - * - * @param align alignment to order - * @param tree tree which has - * - * @return DOCUMENT ME! - */ - private static Vector getOrderByTree(AlignmentI align, NJTree tree) + if (sortOrderAscending) { - int nSeq = align.getHeight(); + setOrder(align, tmp); + } + else + { + setReverseOrder(align, + vectorSubsetToArray(tmp, align.getSequences())); + } + } - Vector tmp = new Vector(); + /** + * DOCUMENT ME! + * + * @param align alignment to order + * @param tree tree which has + * + * @return DOCUMENT ME! + */ + private static Vector getOrderByTree(AlignmentI align, NJTree tree) + { + int nSeq = align.getHeight(); - tmp = _sortByTree(tree.getTopNode(), tmp, align.getSequences()); + Vector tmp = new Vector(); - if (tmp.size() != nSeq) - { - // TODO: JBPNote - decide if this is always an error - // (eg. not when a tree is associated to another alignment which has more - // sequences) - if (tmp.size() < nSeq) - { - addStrays(align, tmp); - } - - if (tmp.size() != nSeq) - { - System.err.println("ERROR: tmp.size()=" + tmp.size() + - " != nseq=" + nSeq + " in getOrderByTree"); - } - } + tmp = _sortByTree(tree.getTopNode(), tmp, align.getSequences()); - return tmp; + if (tmp.size() != nSeq) + { + // TODO: JBPNote - decide if this is always an error + // (eg. not when a tree is associated to another alignment which has more + // sequences) + if (tmp.size() < nSeq) + { + addStrays(align, tmp); + } + + if (tmp.size() != nSeq) + { + System.err.println("ERROR: tmp.size()=" + tmp.size() + + " != nseq=" + nSeq + " in getOrderByTree"); + } } - /** - * Sorts the alignment by a given tree - * - * @param align alignment to order - * @param tree tree which has - */ - public static void sortByTree(AlignmentI align, NJTree tree) + return tmp; + } + + /** + * Sorts the alignment by a given tree + * + * @param align alignment to order + * @param tree tree which has + */ + public static void sortByTree(AlignmentI align, NJTree tree) + { + Vector tmp = getOrderByTree(align, tree); + + // tmp should properly permute align with tree. + if (lastTree != tree) { - Vector tmp = getOrderByTree(align, tree); - - // tmp should properly permute align with tree. - if (lastTree != tree) - { - sortTreeAscending = true; - lastTree = tree; - } - else - { - sortTreeAscending = !sortTreeAscending; - } - - if (sortTreeAscending) - { - setOrder(align, tmp); - } - else - { - setReverseOrder(align, - vectorSubsetToArray(tmp, align.getSequences())); - } + sortTreeAscending = true; + lastTree = tree; } - - /** - * DOCUMENT ME! - * - * @param align DOCUMENT ME! - * @param seqs DOCUMENT ME! - */ - private static void addStrays(AlignmentI align, Vector seqs) + else { - int nSeq = align.getHeight(); - - for (int i = 0; i < nSeq; i++) - { - if (!seqs.contains(align.getSequenceAt(i))) - { - seqs.addElement(align.getSequenceAt(i)); - } - } + sortTreeAscending = !sortTreeAscending; + } - if (nSeq != seqs.size()) - { - System.err.println( - "ERROR: Size still not right even after addStrays"); - } + if (sortTreeAscending) + { + setOrder(align, tmp); + } + else + { + setReverseOrder(align, + vectorSubsetToArray(tmp, align.getSequences())); + } + } + + /** + * DOCUMENT ME! + * + * @param align DOCUMENT ME! + * @param seqs DOCUMENT ME! + */ + private static void addStrays(AlignmentI align, Vector seqs) + { + int nSeq = align.getHeight(); + + for (int i = 0; i < nSeq; i++) + { + if (!seqs.contains(align.getSequenceAt(i))) + { + seqs.addElement(align.getSequenceAt(i)); + } } - /** - * DOCUMENT ME! - * - * @param node DOCUMENT ME! - * @param tmp DOCUMENT ME! - * @param seqset DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - private static Vector _sortByTree(SequenceNode node, Vector tmp, - Vector seqset) + if (nSeq != seqs.size()) { - if (node == null) - { - return tmp; - } + System.err.println( + "ERROR: Size still not right even after addStrays"); + } + } + + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param tmp DOCUMENT ME! + * @param seqset DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private static Vector _sortByTree(SequenceNode node, Vector tmp, + Vector seqset) + { + if (node == null) + { + return tmp; + } - SequenceNode left = (SequenceNode) node.left(); - SequenceNode right = (SequenceNode) node.right(); + SequenceNode left = (SequenceNode) node.left(); + SequenceNode right = (SequenceNode) node.right(); - if ((left == null) && (right == null)) - { - if (!node.isPlaceholder() && (node.element() != null)) - { - if (node.element() instanceof SequenceI) - { - if (!tmp.contains(node.element())) - { - tmp.addElement((SequenceI) node.element()); - } - } - } - - return tmp; - } - else + if ( (left == null) && (right == null)) + { + if (!node.isPlaceholder() && (node.element() != null)) + { + if (node.element() instanceof SequenceI) { - _sortByTree(left, tmp, seqset); - _sortByTree(right, tmp, seqset); + if (!tmp.contains(node.element())) + { + tmp.addElement( (SequenceI) node.element()); + } } + } - return tmp; + return tmp; + } + else + { + _sortByTree(left, tmp, seqset); + _sortByTree(right, tmp, seqset); } - // Ordering Objects - // Alignment.sortBy(OrderObj) - sequence of sequence pointer refs in appropriate order - // + return tmp; + } - /** - * recover the order of sequences given by the safe numbering scheme introducd - * SeqsetUtils.uniquify. - */ - public static void recoverOrder(SequenceI[] alignment) - { - float[] ids = new float[alignment.length]; + // Ordering Objects + // Alignment.sortBy(OrderObj) - sequence of sequence pointer refs in appropriate order + // - for (int i = 0; i < alignment.length; i++) - ids[i] = (new Float(alignment[i].getName().substring(8))).floatValue(); + /** + * recover the order of sequences given by the safe numbering scheme introducd + * SeqsetUtils.uniquify. + */ + public static void recoverOrder(SequenceI[] alignment) + { + float[] ids = new float[alignment.length]; - jalview.util.QuickSort.sort(ids, alignment); + for (int i = 0; i < alignment.length; i++) + { + ids[i] = (new Float(alignment[i].getName().substring(8))).floatValue(); } + + jalview.util.QuickSort.sort(ids, alignment); + } } diff --git a/src/jalview/analysis/Conservation.java b/src/jalview/analysis/Conservation.java index b1cc250..4eb1218 100755 --- a/src/jalview/analysis/Conservation.java +++ b/src/jalview/analysis/Conservation.java @@ -1,27 +1,26 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.analysis; -import jalview.datamodel.*; - import java.util.*; +import jalview.datamodel.*; /** * Calculates conservation values for a given set of sequences @@ -31,516 +30,521 @@ import java.util.*; */ public class Conservation { - SequenceI [] sequences; - int start; - int end; - Vector seqNums; // vector of int vectors where first is sequence checksum - int maxLength = 0; // used by quality calcs - boolean seqNumsChanged = false; // updated after any change via calcSeqNum; - Hashtable [] total; - - /** Stores calculated quality values */ - public Vector quality; - - /** Stores maximum and minimum values of quality values */ - public Double[] qualityRange = new Double[2]; - String consString = ""; - Sequence consSequence; - Hashtable propHash; - int threshold; - String name = ""; - int[][] cons2; - - /** - * Creates a new Conservation object. - * - * @param name Name of conservation - * @param propHash DOCUMENT ME! - * @param threshold to count the residues in residueHash(). commonly used value is 3 - * @param sequences sequences to be used in calculation - * @param start start residue position - * @param end end residue position - */ - public Conservation(String name, Hashtable propHash, int threshold, - Vector sequences, int start, int end) + SequenceI[] sequences; + int start; + int end; + Vector seqNums; // vector of int vectors where first is sequence checksum + int maxLength = 0; // used by quality calcs + boolean seqNumsChanged = false; // updated after any change via calcSeqNum; + Hashtable[] total; + + /** Stores calculated quality values */ + public Vector quality; + + /** Stores maximum and minimum values of quality values */ + public Double[] qualityRange = new Double[2]; + String consString = ""; + Sequence consSequence; + Hashtable propHash; + int threshold; + String name = ""; + int[][] cons2; + + /** + * Creates a new Conservation object. + * + * @param name Name of conservation + * @param propHash DOCUMENT ME! + * @param threshold to count the residues in residueHash(). commonly used value is 3 + * @param sequences sequences to be used in calculation + * @param start start residue position + * @param end end residue position + */ + public Conservation(String name, Hashtable propHash, int threshold, + Vector sequences, int start, int end) + { + + this.name = name; + this.propHash = propHash; + this.threshold = threshold; + this.start = start; + this.end = end; + + maxLength = end - start + 1; // default width includes bounds of calculation + + int s, sSize = sequences.size(); + SequenceI[] sarray = new SequenceI[sSize]; + this.sequences = sarray; + + for (s = 0; s < sSize; s++) { - - this.name = name; - this.propHash = propHash; - this.threshold = threshold; - this.start = start; - this.end = end; - - maxLength=end-start+1; // default width includes bounds of calculation - - int s, sSize = sequences.size(); - SequenceI[] sarray = new SequenceI[sSize]; - this.sequences = sarray; - - for (s = 0; s < sSize; s++) - { - sarray[s] = (SequenceI) sequences.elementAt(s); - if(sarray[s].getLength()>maxLength) - maxLength = sarray[s].getLength(); - } + sarray[s] = (SequenceI) sequences.elementAt(s); + if (sarray[s].getLength() > maxLength) + { + maxLength = sarray[s].getLength(); + } } + } + + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + private void calcSeqNum(int i) + { + String sq = null; // for dumb jbuilder not-inited exception warning + int[] sqnum = null; + int sSize = sequences.length; - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - */ - private void calcSeqNum(int i) + if ( (i > -1) && (i < sSize)) { - String sq = null; // for dumb jbuilder not-inited exception warning - int[] sqnum = null; + sq = sequences[i].getSequenceAsString(); + + if (seqNums.size() <= i) + { + seqNums.addElement(new int[sq.length() + 1]); + } - int sSize = sequences.length; + if (sq.hashCode() != ( (int[]) seqNums.elementAt(i))[0]) + { + int j; + int len; + seqNumsChanged = true; + len = sq.length(); - if ((i > -1) && (i < sSize)) + if (maxLength < len) { - sq = sequences[i].getSequenceAsString(); + maxLength = len; + } - if (seqNums.size() <= i) - { - seqNums.addElement(new int[sq.length() + 1]); - } + sqnum = new int[len + 1]; // better to always make a new array - sequence can change its length + sqnum[0] = sq.hashCode(); - if (sq.hashCode() != ((int[]) seqNums.elementAt(i))[0]) - { - int j; - int len; - seqNumsChanged = true; - len = sq.length(); + for (j = 1; j <= len; j++) + { + sqnum[j] = jalview.schemes.ResidueProperties.aaIndex[sq.charAt(j - 1)]; + } - if (maxLength < len) - { - maxLength = len; - } + seqNums.setElementAt(sqnum, i); + } + else + { + System.out.println("SEQUENCE HAS BEEN DELETED!!!"); + } + } + else + { + // JBPNote INFO level debug + System.err.println( + "ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); + } + } + + /** + * Calculates the conservation values for given set of sequences + */ + public void calculate() + { + Hashtable resultHash, ht; + int thresh, j, jSize = sequences.length; + int[] values; // Replaces residueHash + String type, res = null; + char c; + Enumeration enumeration2; + + total = new Hashtable[maxLength]; + + for (int i = start; i <= end; i++) + { + values = new int[255]; - sqnum = new int[len + 1]; // better to always make a new array - sequence can change its length - sqnum[0] = sq.hashCode(); + for (j = 0; j < jSize; j++) + { + if (sequences[j].getLength() > i) + { + c = sequences[j].getCharAt(i); - for (j = 1; j <= len; j++) - { - sqnum[j] = jalview.schemes.ResidueProperties.aaIndex[sq.charAt(j-1)]; - } + // No need to check if its a '-' + if (c == '.' || c == ' ') + { + c = '-'; + } + if ('a' <= c && c <= 'z') + { + c -= (32); // 32 = 'a' - 'A' + } - seqNums.setElementAt(sqnum, i); - } - else - System.out.println("SEQUENCE HAS BEEN DELETED!!!"); + values[c]++; } else { - // JBPNote INFO level debug - System.err.println( - "ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); + values['-']++; } - } + } - /** - * Calculates the conservation values for given set of sequences - */ - public void calculate() - { - Hashtable resultHash, ht; - int thresh, j, jSize = sequences.length; - int[] values; // Replaces residueHash - String type, res=null; - char c; - Enumeration enumeration2; + //What is the count threshold to count the residues in residueHash() + thresh = (threshold * (jSize)) / 100; - total = new Hashtable[maxLength]; + //loop over all the found residues + resultHash = new Hashtable(); + for (char v = '-'; v < 'Z'; v++) + { - for (int i = start; i <= end; i++) + if (values[v] > thresh) { - values = new int[255]; + res = String.valueOf(v); - for (j = 0; j < jSize; j++) - { - if (sequences[j].getLength() > i) - { - c = sequences[j].getCharAt(i); - - // No need to check if its a '-' - if (c == '.' || c == ' ') - c = '-'; + //Now loop over the properties + enumeration2 = propHash.keys(); - if ('a' <= c && c <= 'z') - { - c -= (32);// 32 = 'a' - 'A' - } + while (enumeration2.hasMoreElements()) + { + type = (String) enumeration2.nextElement(); + ht = (Hashtable) propHash.get(type); - values[c]++; + //Have we ticked this before? + if (!resultHash.containsKey(type)) + { + if (ht.containsKey(res)) + { + resultHash.put(type, ht.get(res)); } else { - values['-']++; + resultHash.put(type, ht.get("-")); } } - - //What is the count threshold to count the residues in residueHash() - thresh = (threshold * (jSize)) / 100; - - //loop over all the found residues - resultHash = new Hashtable(); - for (char v = '-'; v < 'Z'; v++) + else if ( ( (Integer) resultHash.get(type)).equals( + (Integer) ht.get(res)) == false) { - - if (values[v] > thresh) - { - res = String.valueOf( v ); - - //Now loop over the properties - enumeration2 = propHash.keys(); - - while (enumeration2.hasMoreElements()) - { - type = (String) enumeration2.nextElement(); - ht = (Hashtable) propHash.get(type); - - //Have we ticked this before? - if (!resultHash.containsKey(type)) - { - if (ht.containsKey(res)) - { - resultHash.put(type, ht.get(res)); - } - else - { - resultHash.put(type, ht.get("-")); - } - } - else if (((Integer) resultHash.get(type)).equals( - (Integer) ht.get(res)) == false) - { - resultHash.put(type, new Integer(-1)); - } - } - } + resultHash.put(type, new Integer( -1)); } - - total[i-start] = resultHash; + } } - } - + } - /*** - * countConsNGaps - * returns gap count in int[0], and conserved residue count in int[1] - */ - public int[] countConsNGaps(int j) + total[i - start] = resultHash; + } + } + + /*** + * countConsNGaps + * returns gap count in int[0], and conserved residue count in int[1] + */ + public int[] countConsNGaps(int j) + { + int count = 0; + int cons = 0; + int nres = 0; + int[] r = new int[2]; + char f = '$'; + int i, iSize = sequences.length; + char c; + + for (i = 0; i < iSize; i++) { - int count = 0; - int cons = 0; - int nres = 0; - int[] r = new int[2]; - char f = '$'; - int i, iSize = sequences.length; - char c; - - for (i = 0; i < iSize; i++) - { - if (j >= sequences[i].getLength()) - { - count++; - continue; - } + if (j >= sequences[i].getLength()) + { + count++; + continue; + } - c = sequences[i].getCharAt(j); // gaps do not have upper/lower case + c = sequences[i].getCharAt(j); // gaps do not have upper/lower case - if (jalview.util.Comparison.isGap((c))) - { - count++; - } - else - { - nres++; - - if (nres == 1) - { - f = c; - cons++; - } - else if (f == c) - { - cons++; - } - } - } + if (jalview.util.Comparison.isGap( (c))) + { + count++; + } + else + { + nres++; - r[0] = (nres == cons) ? 1 : 0; - r[1] = count; + if (nres == 1) + { + f = c; + cons++; + } + else if (f == c) + { + cons++; + } + } + } - return r; + r[0] = (nres == cons) ? 1 : 0; + r[1] = count; + + return r; + } + + /** + * Calculates the conservation sequence + * + * @param consflag if true, poitiveve conservation; false calculates negative conservation + * @param percentageGaps commonly used value is 25 + */ + public void verdict(boolean consflag, float percentageGaps) + { + StringBuffer consString = new StringBuffer(); + String type; + Integer result; + int[] gapcons; + int totGaps, count; + float pgaps; + Hashtable resultHash; + Enumeration enumeration; + + //NOTE THIS SHOULD CHECK IF THE CONSEQUENCE ALREADY + //EXISTS AND NOT OVERWRITE WITH '-', BUT THIS CASE + //DOES NOT EXIST IN JALVIEW 2.1.2 + for (int i = 0; i < start; i++) + { + consString.append('-'); } - /** - * Calculates the conservation sequence - * - * @param consflag if true, poitiveve conservation; false calculates negative conservation - * @param percentageGaps commonly used value is 25 - */ - public void verdict(boolean consflag, float percentageGaps) + for (int i = start; i <= end; i++) { - StringBuffer consString = new StringBuffer(); - String type; - Integer result; - int[] gapcons; - int totGaps, count; - float pgaps; - Hashtable resultHash ; - Enumeration enumeration; - - //NOTE THIS SHOULD CHECK IF THE CONSEQUENCE ALREADY - //EXISTS AND NOT OVERWRITE WITH '-', BUT THIS CASE - //DOES NOT EXIST IN JALVIEW 2.1.2 - for(int i=0; i pgaps) + { + resultHash = total[i - start]; + + //Now find the verdict + count = 0; + enumeration = resultHash.keys(); + + while (enumeration.hasMoreElements()) { - gapcons = countConsNGaps(i); - totGaps = gapcons[1]; - pgaps = ((float) totGaps * 100) / (float) sequences.length; + type = (String) enumeration.nextElement(); + result = (Integer) resultHash.get(type); - if (percentageGaps > pgaps) + //Do we want to count +ve conservation or +ve and -ve cons.? + if (consflag) + { + if (result.intValue() == 1) { - resultHash = total[i - start]; - - //Now find the verdict - count = 0; - enumeration = resultHash.keys(); - - while (enumeration.hasMoreElements()) - { - type = (String) enumeration.nextElement(); - result = (Integer) resultHash.get(type); - - //Do we want to count +ve conservation or +ve and -ve cons.? - if (consflag) - { - if (result.intValue() == 1) - { - count++; - } - } - else - { - if (result.intValue() != -1) - { - count++; - } - } - } - - if (count < 10) - { - consString.append(count); // Conserved props!=Identity - } - else - { - consString.append((gapcons[0] == 1) ? "*" : "+"); - } + count++; } - else + } + else + { + if (result.intValue() != -1) { - consString.append('-'); + count++; } + } } - consSequence = new Sequence(name, consString.toString(), start, end); + if (count < 10) + { + consString.append(count); // Conserved props!=Identity + } + else + { + consString.append( (gapcons[0] == 1) ? "*" : "+"); + } + } + else + { + consString.append('-'); + } } - /** - * - * - * @return Conservation sequence - */ - public Sequence getConsSequence() + consSequence = new Sequence(name, consString.toString(), start, end); + } + + /** + * + * + * @return Conservation sequence + */ + public Sequence getConsSequence() + { + return consSequence; + } + + // From Alignment.java in jalview118 + public void findQuality() + { + findQuality(0, maxLength - 1); + } + + /** + * DOCUMENT ME! + */ + private void percentIdentity2() + { + seqNums = new Vector(); + // calcSeqNum(s); + int i = 0, iSize = sequences.length; + //Do we need to calculate this again? + for (i = 0; i < iSize; i++) { - return consSequence; + calcSeqNum(i); } - // From Alignment.java in jalview118 - public void findQuality() + if ( (cons2 == null) || seqNumsChanged) { - findQuality(0, maxLength - 1); - } + cons2 = new int[maxLength][24]; - /** - * DOCUMENT ME! - */ - private void percentIdentity2() - { - seqNums = new Vector(); - // calcSeqNum(s); - int i = 0, iSize = sequences.length; - //Do we need to calculate this again? - for (i = 0; i < iSize; i++) + // Initialize the array + for (int j = 0; j < 24; j++) { - calcSeqNum(i); - } - - - if ((cons2 == null) || seqNumsChanged) + for (i = 0; i < maxLength; i++) { - cons2 = new int[maxLength][24]; - - // Initialize the array - for (int j = 0; j < 24; j++) - { - for (i = 0; i < maxLength; i++) - { - cons2[i][j] = 0; - } - } + cons2[i][j] = 0; + } + } - int[] sqnum; - int j = 0; + int[] sqnum; + int j = 0; - while (j < sequences.length) - { - sqnum = (int[]) seqNums.elementAt(j); + while (j < sequences.length) + { + sqnum = (int[]) seqNums.elementAt(j); - for (i = 1; i < sqnum.length; i++) - { - cons2[i - 1][sqnum[i]]++; - } + for (i = 1; i < sqnum.length; i++) + { + cons2[i - 1][sqnum[i]]++; + } - for (i = sqnum.length - 1; i < maxLength; i++) - { - cons2[i][23]++; // gap count - } + for (i = sqnum.length - 1; i < maxLength; i++) + { + cons2[i][23]++; // gap count + } - j++; - } + j++; + } - // unnecessary ? + // unnecessary ? - /* for (int i=start; i <= end; i++) { - int max = -1000; - int maxi = -1; - int maxj = -1; + /* for (int i=start; i <= end; i++) { + int max = -1000; + int maxi = -1; + int maxj = -1; - for (int j=0;j<24;j++) { - if (cons2[i][j] > max) { - max = cons2[i][j]; - maxi = i; - maxj = j; - } + for (int j=0;j<24;j++) { + if (cons2[i][j] > max) { + max = cons2[i][j]; + maxi = i; + maxj = j; + } - } - } */ - } + } + } */ } - - /** - * Calculates the quality of the set of sequences - * - * @param start Start residue - * @param end End residue - */ - public void findQuality(int start, int end) + } + + /** + * Calculates the quality of the set of sequences + * + * @param start Start residue + * @param end End residue + */ + public void findQuality(int start, int end) + { + quality = new Vector(); + + double max = -10000; + int[][] BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62(); + + //Loop over columns // JBPNote Profiling info + //long ts = System.currentTimeMillis(); + //long te = System.currentTimeMillis(); + percentIdentity2(); + + int size = seqNums.size(); + int[] lengths = new int[size]; + double tot, bigtot, sr, tmp; + double[] x, xx; + int l, j, i, ii, i2, k, seqNum; + + for (l = 0; l < size; l++) { - quality = new Vector(); - - double max = -10000; - int[][] BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62(); + lengths[l] = ( (int[]) seqNums.elementAt(l)).length - 1; + } - //Loop over columns // JBPNote Profiling info - //long ts = System.currentTimeMillis(); - //long te = System.currentTimeMillis(); - percentIdentity2(); + for (j = start; j <= end; j++) + { + bigtot = 0; - int size = seqNums.size(); - int[] lengths = new int[size]; - double tot, bigtot, sr, tmp; - double [] x, xx; - int l, j, i, ii, i2, k, seqNum; + // First Xr = depends on column only + x = new double[24]; - for (l = 0; l < size; l++) - lengths[l] = ((int[]) seqNums.elementAt(l)).length - 1; + for (ii = 0; ii < 24; ii++) + { + x[ii] = 0; - for (j = start; j <= end; j++) + for (i2 = 0; i2 < 24; i2++) { - bigtot = 0; - - // First Xr = depends on column only - x = new double[24]; - - for (ii = 0; ii < 24; ii++) - { - x[ii] = 0; - - for (i2 = 0; i2 < 24; i2++) - { - x[ii] += ( ( (double) cons2[j][i2] * BLOSUM62[ii][i2]) + - 4); - } - - x[ii] /= size; - } + x[ii] += ( ( (double) cons2[j][i2] * BLOSUM62[ii][i2]) + + 4); + } - // Now calculate D for each position and sum - for (k = 0; k < size; k++) - { - tot = 0; - xx = new double[24]; - seqNum = (j < lengths[k]) - ? ((int[]) seqNums.elementAt(k))[j + 1] : 23; // Sequence, or gap at the end + x[ii] /= size; + } - // This is a loop over r - for (i = 0; i < 23; i++) - { - sr = 0; + // Now calculate D for each position and sum + for (k = 0; k < size; k++) + { + tot = 0; + xx = new double[24]; + seqNum = (j < lengths[k]) + ? ( (int[]) seqNums.elementAt(k))[j + 1] : 23; // Sequence, or gap at the end - sr = (double) BLOSUM62[i][seqNum] + 4; + // This is a loop over r + for (i = 0; i < 23; i++) + { + sr = 0; - //Calculate X with another loop over residues - // System.out.println("Xi " + i + " " + x[i] + " " + sr); - xx[i] = x[i] - sr; + sr = (double) BLOSUM62[i][seqNum] + 4; - tot += (xx[i] * xx[i]); - } + //Calculate X with another loop over residues + // System.out.println("Xi " + i + " " + x[i] + " " + sr); + xx[i] = x[i] - sr; - bigtot += Math.sqrt(tot); - } + tot += (xx[i] * xx[i]); + } - // This is the quality for one column - if (max < bigtot) - { - max = bigtot; - } + bigtot += Math.sqrt(tot); + } - // bigtot = bigtot * (size-cons2[j][23])/size; - quality.addElement(new Double(bigtot)); + // This is the quality for one column + if (max < bigtot) + { + max = bigtot; + } - // Need to normalize by gaps - } + // bigtot = bigtot * (size-cons2[j][23])/size; + quality.addElement(new Double(bigtot)); - double newmax = -10000; + // Need to normalize by gaps + } - for (j = start; j <= end; j++) - { - tmp = ((Double) quality.elementAt(j)).doubleValue(); - tmp = ((max - tmp) * (size - cons2[j][23])) / size; + double newmax = -10000; - // System.out.println(tmp+ " " + j); - quality.setElementAt(new Double(tmp), j); + for (j = start; j <= end; j++) + { + tmp = ( (Double) quality.elementAt(j)).doubleValue(); + tmp = ( (max - tmp) * (size - cons2[j][23])) / size; - if (tmp > newmax) - { - newmax = tmp; - } - } + // System.out.println(tmp+ " " + j); + quality.setElementAt(new Double(tmp), j); - // System.out.println("Quality " + s); - qualityRange[0] = new Double(0); - qualityRange[1] = new Double(newmax); + if (tmp > newmax) + { + newmax = tmp; + } } + + // System.out.println("Quality " + s); + qualityRange[0] = new Double(0); + qualityRange[1] = new Double(newmax); + } } diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index 479c8561..2fa09aa 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -1,273 +1,308 @@ package jalview.analysis; -import java.util.Vector; + +import java.util.*; import jalview.datamodel.*; -public class Finder { - /** - * Implements the search algorithms for the Find dialog box. - */ - SearchResults searchResults; - AlignmentI alignment; - jalview.datamodel.SequenceGroup selection=null; - Vector idMatch=null; - boolean caseSensitive=false; - boolean findAll=false; - com.stevesoft.pat.Regex regex=null; - /** - * hold's last-searched position between calles to find(false) - */ - int seqIndex=0,resIndex=0; - public Finder(AlignmentI alignment, SequenceGroup selection) { - this.alignment=alignment; - this.selection = selection; +public class Finder +{ + /** + * Implements the search algorithms for the Find dialog box. + */ + SearchResults searchResults; + AlignmentI alignment; + jalview.datamodel.SequenceGroup selection = null; + Vector idMatch = null; + boolean caseSensitive = false; + boolean findAll = false; + com.stevesoft.pat.Regex regex = null; + /** + * hold's last-searched position between calles to find(false) + */ + int seqIndex = 0, resIndex = 0; + public Finder(AlignmentI alignment, SequenceGroup selection) + { + this.alignment = alignment; + this.selection = selection; + } + + public Finder(AlignmentI alignment, SequenceGroup selectionGroup, + int seqIndex, int resIndex) + { + this(alignment, selectionGroup); + this.seqIndex = seqIndex; + this.resIndex = resIndex; + } + + public boolean find(String searchString) + { + boolean hasResults = false; + if (!caseSensitive) + { + searchString = searchString.toUpperCase(); + } + regex = new com.stevesoft.pat.Regex(searchString); + searchResults = new SearchResults(); + idMatch = new Vector(); + Sequence seq; + String item = null; + boolean found = false; + + ////// is the searchString a residue number? + try + { + int res = Integer.parseInt(searchString); + found = true; + if (selection == null || selection.getSize() < 1) + { + seq = (Sequence) alignment.getSequenceAt(0); + } + else + { + seq = (Sequence) (selection.getSequenceAt(0)); + } + + searchResults.addResult(seq, res, res); + hasResults = true; } + catch (NumberFormatException ex) + { + } + + /////////////////////////////////////////////// - public Finder(AlignmentI alignment, SequenceGroup selectionGroup, int seqIndex, int resIndex) { - this(alignment, selectionGroup); - this.seqIndex=seqIndex; - this.resIndex=resIndex; + int end = alignment.getHeight(); + + if (selection != null) + { + if ( (selection.getSize() < 1) || + ( (selection.getEndRes() - selection.getStartRes()) < 2)) + { + selection = null; + } } - public boolean find(String searchString) { - boolean hasResults=false; - if(!caseSensitive) - searchString = searchString.toUpperCase(); - regex = new com.stevesoft.pat.Regex(searchString); - searchResults = new SearchResults(); - idMatch = new Vector(); - Sequence seq; - String item = null; - boolean found = false; - - ////// is the searchString a residue number? - try + while (!found && (seqIndex < end)) + { + seq = (Sequence) alignment.getSequenceAt(seqIndex); + + if ( (selection != null) && !selection.getSequences(null).contains(seq)) + { + seqIndex++; + resIndex = 0; + + continue; + } + + item = seq.getSequenceAsString(); + // JBPNote - check if this toUpper which is present in the application implementation makes a difference + //if(!caseSensitive) + // item = item.toUpperCase(); + + if ( (selection != null) && + (selection.getEndRes() < alignment.getWidth() - 1)) + { + item = item.substring(0, selection.getEndRes() + 1); + } + + ///Shall we ignore gaps???? - JBPNote: Add Flag for forcing this or not + StringBuffer noGapsSB = new StringBuffer(); + int insertCount = 0; + Vector spaces = new Vector(); + + for (int j = 0; j < item.length(); j++) + { + if (!jalview.util.Comparison.isGap(item.charAt(j))) { - int res = Integer.parseInt(searchString); - found = true; - if (selection == null || selection.getSize() < 1) - { - seq = (Sequence) alignment.getSequenceAt(0); - } - else - { - seq = (Sequence) (selection.getSequenceAt(0)); - } - - searchResults.addResult(seq, res, res); - hasResults=true; + noGapsSB.append(item.charAt(j)); + spaces.addElement(new Integer(insertCount)); } - catch (NumberFormatException ex) + else { + insertCount++; } + } - /////////////////////////////////////////////// - - int end = alignment.getHeight(); + String noGaps = noGapsSB.toString(); + for (int r = resIndex; r < noGaps.length(); r++) + { - if (selection != null) + if (regex.searchFrom(noGaps, r)) { - if ((selection.getSize() < 1) || - ((selection.getEndRes() - selection.getStartRes()) < 2)) - { - selection = null; - } - } + resIndex = regex.matchedFrom(); + + if ( (selection != null) && + ( (resIndex + + Integer.parseInt(spaces.elementAt(resIndex).toString())) < + selection.getStartRes())) + { + continue; + } + + int sres = seq.findPosition(resIndex + + Integer.parseInt(spaces.elementAt( + resIndex) + .toString())); + int eres = seq.findPosition(regex.matchedTo() - 1 + + Integer.parseInt(spaces.elementAt(regex. + matchedTo() - + 1).toString())); + + searchResults.addResult(seq, sres, eres); + hasResults = true; + if (!findAll) + { + // thats enough, break and display the result + found = true; + resIndex++; - while (!found && (seqIndex < end)) - { - seq = (Sequence) alignment.getSequenceAt(seqIndex); - - if ((selection != null) && !selection.getSequences(null).contains(seq)) - { - seqIndex++; - resIndex = 0; - - continue; - } - - item = seq.getSequenceAsString(); - // JBPNote - check if this toUpper which is present in the application implementation makes a difference - //if(!caseSensitive) - // item = item.toUpperCase(); - - if ((selection != null) && - (selection.getEndRes() < alignment.getWidth()-1)) - { - item = item.substring(0, selection.getEndRes() + 1); - } - - ///Shall we ignore gaps???? - JBPNote: Add Flag for forcing this or not - StringBuffer noGapsSB = new StringBuffer(); - int insertCount = 0; - Vector spaces = new Vector(); - - for (int j = 0; j < item.length(); j++) - { - if (!jalview.util.Comparison.isGap(item.charAt(j))) - { - noGapsSB.append(item.charAt(j)); - spaces.addElement(new Integer(insertCount)); - } - else - { - insertCount++; - } - } - - String noGaps = noGapsSB.toString(); - - for (int r = resIndex; r < noGaps.length(); r++) - { - - if (regex.searchFrom(noGaps, r)) - { - resIndex = regex.matchedFrom(); - - if ((selection != null) && - ((resIndex + - Integer.parseInt(spaces.elementAt(resIndex).toString())) < selection.getStartRes())) - { - continue; - } - - - int sres = seq.findPosition(resIndex + - Integer.parseInt(spaces.elementAt(resIndex) - .toString())); - int eres = seq.findPosition(regex.matchedTo() - 1 + - Integer.parseInt(spaces.elementAt(regex.matchedTo() - - 1).toString())); - - searchResults.addResult(seq, sres, eres); - hasResults=true; - if (!findAll) - { - // thats enough, break and display the result - found = true; - resIndex++; - - break; - } - - r = resIndex; - } - else - { - break; - } - } - - if (!found) - { - seqIndex++; - resIndex = 0; - } - } + break; + } - for (int id = 0; id < alignment.getHeight(); id++) + r = resIndex; + } + else { - if (regex.search(alignment.getSequenceAt(id).getName())) - { - idMatch.addElement(alignment.getSequenceAt(id)); - hasResults=true; - } + break; } - return hasResults; - } - /** - * @return the alignment - */ - public AlignmentI getAlignment() { - return alignment; - } - /** - * @param alignment the alignment to set - */ - public void setAlignment(AlignmentI alignment) { - this.alignment = alignment; - } - /** - * @return the caseSensitive - */ - public boolean isCaseSensitive() { - return caseSensitive; - } - /** - * @param caseSensitive the caseSensitive to set - */ - public void setCaseSensitive(boolean caseSensitive) { - this.caseSensitive = caseSensitive; - } - /** - * @return the findAll - */ - public boolean isFindAll() { - return findAll; - } - /** - * @param findAll the findAll to set - */ - public void setFindAll(boolean findAll) { - this.findAll = findAll; - } - /** - * @return the selection - */ - public jalview.datamodel.SequenceGroup getSelection() { - return selection; - } - /** - * @param selection the selection to set - */ - public void setSelection(jalview.datamodel.SequenceGroup selection) { - this.selection = selection; - } - /** - * @return the idMatch - */ - public Vector getIdMatch() { - return idMatch; - } - /** - * @return the regex - */ - public com.stevesoft.pat.Regex getRegex() { - return regex; - } - /** - * @return the searchResults - */ - public SearchResults getSearchResults() { - return searchResults; - } - - /** - * @return the resIndex - */ - public int getResIndex() { - return resIndex; - } - - /** - * @param resIndex the resIndex to set - */ - public void setResIndex(int resIndex) { - this.resIndex = resIndex; - } + } - /** - * @return the seqIndex - */ - public int getSeqIndex() { - return seqIndex; + if (!found) + { + seqIndex++; + resIndex = 0; + } } - /** - * @param seqIndex the seqIndex to set - */ - public void setSeqIndex(int seqIndex) { - this.seqIndex = seqIndex; + for (int id = 0; id < alignment.getHeight(); id++) + { + if (regex.search(alignment.getSequenceAt(id).getName())) + { + idMatch.addElement(alignment.getSequenceAt(id)); + hasResults = true; + } } + return hasResults; + } + + /** + * @return the alignment + */ + public AlignmentI getAlignment() + { + return alignment; + } + + /** + * @param alignment the alignment to set + */ + public void setAlignment(AlignmentI alignment) + { + this.alignment = alignment; + } + + /** + * @return the caseSensitive + */ + public boolean isCaseSensitive() + { + return caseSensitive; + } + + /** + * @param caseSensitive the caseSensitive to set + */ + public void setCaseSensitive(boolean caseSensitive) + { + this.caseSensitive = caseSensitive; + } + + /** + * @return the findAll + */ + public boolean isFindAll() + { + return findAll; + } + + /** + * @param findAll the findAll to set + */ + public void setFindAll(boolean findAll) + { + this.findAll = findAll; + } + + /** + * @return the selection + */ + public jalview.datamodel.SequenceGroup getSelection() + { + return selection; + } + + /** + * @param selection the selection to set + */ + public void setSelection(jalview.datamodel.SequenceGroup selection) + { + this.selection = selection; + } + + /** + * @return the idMatch + */ + public Vector getIdMatch() + { + return idMatch; + } + + /** + * @return the regex + */ + public com.stevesoft.pat.Regex getRegex() + { + return regex; + } + + /** + * @return the searchResults + */ + public SearchResults getSearchResults() + { + return searchResults; + } + + /** + * @return the resIndex + */ + public int getResIndex() + { + return resIndex; + } + + /** + * @param resIndex the resIndex to set + */ + public void setResIndex(int resIndex) + { + this.resIndex = resIndex; + } + + /** + * @return the seqIndex + */ + public int getSeqIndex() + { + return seqIndex; + } + + /** + * @param seqIndex the seqIndex to set + */ + public void setSeqIndex(int seqIndex) + { + this.seqIndex = seqIndex; + } } diff --git a/src/jalview/analysis/NJTree.java b/src/jalview/analysis/NJTree.java index b882ba7..4d0bb93 100755 --- a/src/jalview/analysis/NJTree.java +++ b/src/jalview/analysis/NJTree.java @@ -1,34 +1,29 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.analysis; -import jalview.datamodel.*; - -import jalview.io.NewickFile; - -import jalview.schemes.ResidueProperties; -import jalview.schemes.ScoreMatrix; - -import jalview.util.*; - import java.util.*; +import jalview.datamodel.*; +import jalview.io.*; +import jalview.schemes.*; +import jalview.util.*; /** * DOCUMENT ME! @@ -38,1213 +33,1239 @@ import java.util.*; */ public class NJTree { - Vector cluster; - SequenceI[] sequence; - - //SequenceData is a string representation of what the user - //sees. The display may contain hidden columns. - public AlignmentView seqData=null; - - int[] done; - int noseqs; - int noClus; - float[][] distance; - int mini; - int minj; - float ri; - float rj; - Vector groups = new Vector(); - SequenceNode maxdist; - SequenceNode top; - float maxDistValue; - float maxheight; - int ycount; - Vector node; - String type; - String pwtype; - Object found = null; - Object leaves = null; - - boolean hasDistances = true; // normal case for jalview trees - boolean hasBootstrap = false; // normal case for jalview trees - - private boolean hasRootDistance = true; - - /** - * Create a new NJTree object with leaves associated with sequences in seqs, - * and original alignment data represented by Cigar strings. - * @param seqs SequenceI[] - * @param odata Cigar[] - * @param treefile NewickFile - */ - public NJTree(SequenceI[] seqs, AlignmentView odata, NewickFile treefile) { - this(seqs, treefile); - if (odata!=null) - seqData = odata; - /* - sequenceString = new String[odata.length]; - char gapChar = jalview.util.Comparison.GapChars.charAt(0); - for (int i = 0; i < odata.length; i++) - { - SequenceI oseq_aligned = odata[i].getSeq(gapChar); - sequenceString[i] = oseq_aligned.getSequence(); - } */ + Vector cluster; + SequenceI[] sequence; + + //SequenceData is a string representation of what the user + //sees. The display may contain hidden columns. + public AlignmentView seqData = null; + + int[] done; + int noseqs; + int noClus; + float[][] distance; + int mini; + int minj; + float ri; + float rj; + Vector groups = new Vector(); + SequenceNode maxdist; + SequenceNode top; + float maxDistValue; + float maxheight; + int ycount; + Vector node; + String type; + String pwtype; + Object found = null; + Object leaves = null; + + boolean hasDistances = true; // normal case for jalview trees + boolean hasBootstrap = false; // normal case for jalview trees + + private boolean hasRootDistance = true; + + /** + * Create a new NJTree object with leaves associated with sequences in seqs, + * and original alignment data represented by Cigar strings. + * @param seqs SequenceI[] + * @param odata Cigar[] + * @param treefile NewickFile + */ + public NJTree(SequenceI[] seqs, AlignmentView odata, NewickFile treefile) + { + this(seqs, treefile); + if (odata != null) + { + seqData = odata; } + /* + sequenceString = new String[odata.length]; + char gapChar = jalview.util.Comparison.GapChars.charAt(0); + for (int i = 0; i < odata.length; i++) + { + SequenceI oseq_aligned = odata[i].getSeq(gapChar); + sequenceString[i] = oseq_aligned.getSequence(); + } */ + } + + /** + * Creates a new NJTree object from a tree from an external source + * + * @param seqs SequenceI which should be associated with leafs of treefile + * @param treefile A parsed tree + */ + public NJTree(SequenceI[] seqs, NewickFile treefile) + { + this.sequence = seqs; + top = treefile.getTree(); /** - * Creates a new NJTree object from a tree from an external source + * There is no dependent alignment to be recovered from an + * imported tree. * - * @param seqs SequenceI which should be associated with leafs of treefile - * @param treefile A parsed tree + if (sequenceString == null) + { + sequenceString = new String[seqs.length]; + for (int i = 0; i < seqs.length; i++) + { + sequenceString[i] = seqs[i].getSequence(); + } + } */ - public NJTree(SequenceI[] seqs, NewickFile treefile) - { - this.sequence = seqs; - top = treefile.getTree(); - - /** - * There is no dependent alignment to be recovered from an - * imported tree. - * - if (sequenceString == null) - { - sequenceString = new String[seqs.length]; - for (int i = 0; i < seqs.length; i++) - { - sequenceString[i] = seqs[i].getSequence(); - } - } - */ - hasDistances = treefile.HasDistances(); - hasBootstrap = treefile.HasBootstrap(); - hasRootDistance = treefile.HasRootDistance(); + hasDistances = treefile.HasDistances(); + hasBootstrap = treefile.HasBootstrap(); + hasRootDistance = treefile.HasRootDistance(); - maxheight = findHeight(top); + maxheight = findHeight(top); - SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs); - - Vector leaves = new Vector(); - findLeaves(top, leaves); - - int i = 0; - int namesleft = seqs.length; - - SequenceNode j; - SequenceI nam; - String realnam; - Vector one2many=new Vector(); - int countOne2Many=0; - while (i < leaves.size()) - { - j = (SequenceNode) leaves.elementAt(i++); - realnam = j.getName(); - nam = null; + SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs); - if (namesleft > -1) - { - nam = algnIds.findIdMatch(realnam); - } + Vector leaves = new Vector(); + findLeaves(top, leaves); - if (nam != null) - { - j.setElement(nam); - if (one2many.contains(nam)) { - countOne2Many++; - // if (jalview.bin.Cache.log.isDebugEnabled()) - // jalview.bin.Cache.log.debug("One 2 many relationship for "+nam.getName()); - } else { - one2many.addElement(nam); - namesleft--; - } - } - else - { - j.setElement(new Sequence(realnam, "THISISAPLACEHLDER")); - j.setPlaceholder(true); - } - } - // if (jalview.bin.Cache.log.isDebugEnabled() && countOne2Many>0) { - // jalview.bin.Cache.log.debug("There were "+countOne2Many+" alignment sequence ids (out of "+one2many.size()+" unique ids) linked to two or more leaves."); - // } - // one2many.clear(); - } + int i = 0; + int namesleft = seqs.length; - /** - * Creates a new NJTree object. - * - * @param sequence DOCUMENT ME! - * @param type DOCUMENT ME! - * @param pwtype DOCUMENT ME! - * @param start DOCUMENT ME! - * @param end DOCUMENT ME! - */ - public NJTree(SequenceI[] sequence, - AlignmentView seqData, - String type, - String pwtype, - int start, int end) + SequenceNode j; + SequenceI nam; + String realnam; + Vector one2many = new Vector(); + int countOne2Many = 0; + while (i < leaves.size()) { - this.sequence = sequence; - this.node = new Vector(); - this.type = type; - this.pwtype = pwtype; - if (seqData!=null) { - this.seqData = seqData; - } else { - SeqCigar[] seqs = new SeqCigar[sequence.length]; - for(int i=0; i -1) + { + nam = algnIds.findIdMatch(realnam); + } - if (!(pwtype.equals("PID"))) + if (nam != null) + { + j.setElement(nam); + if (one2many.contains(nam)) { - if (ResidueProperties.getScoreMatrix(pwtype)==null) { - type = "BLOSUM62"; - } + countOne2Many++; + // if (jalview.bin.Cache.log.isDebugEnabled()) + // jalview.bin.Cache.log.debug("One 2 many relationship for "+nam.getName()); } - - int i = 0; - - done = new int[sequence.length]; - - while ((i < sequence.length) && (sequence[i] != null)) + else { - done[i] = 0; - i++; + one2many.addElement(nam); + namesleft--; } - - noseqs = i++; - - distance = findDistances(this.seqData.getSequenceStrings(Comparison.GapChars.charAt(0))); - - makeLeaves(); - - noClus = cluster.size(); - - cluster(); + } + else + { + j.setElement(new Sequence(realnam, "THISISAPLACEHLDER")); + j.setPlaceholder(true); + } } + // if (jalview.bin.Cache.log.isDebugEnabled() && countOne2Many>0) { + // jalview.bin.Cache.log.debug("There were "+countOne2Many+" alignment sequence ids (out of "+one2many.size()+" unique ids) linked to two or more leaves."); + // } + // one2many.clear(); + } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String toString() + /** + * Creates a new NJTree object. + * + * @param sequence DOCUMENT ME! + * @param type DOCUMENT ME! + * @param pwtype DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + */ + public NJTree(SequenceI[] sequence, + AlignmentView seqData, + String type, + String pwtype, + int start, int end) + { + this.sequence = sequence; + this.node = new Vector(); + this.type = type; + this.pwtype = pwtype; + if (seqData != null) { - jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode()); - - return fout.print(false, true); // distances only + this.seqData = seqData; + } + else + { + SeqCigar[] seqs = new SeqCigar[sequence.length]; + for (int i = 0; i < sequence.length; i++) + { + seqs[i] = new SeqCigar(sequence[i], start, end); + } + CigarArray sdata = new CigarArray(seqs); + sdata.addOperation(CigarArray.M, end - start + 1); + this.seqData = new AlignmentView(sdata, start); } - /** - * - * used when the alignment associated to a tree has changed. - * - * @param alignment Vector - */ - public void UpdatePlaceHolders(Vector alignment) + if (! (type.equals("NJ"))) { - Vector leaves = new Vector(); - findLeaves(top, leaves); + type = "AV"; + } - int sz = leaves.size(); - SequenceIdMatcher seqmatcher = null; - int i = 0; + if (! (pwtype.equals("PID"))) + { + if (ResidueProperties.getScoreMatrix(pwtype) == null) + { + type = "BLOSUM62"; + } + } - while (i < sz) - { - SequenceNode leaf = (SequenceNode) leaves.elementAt(i++); + int i = 0; - if (alignment.contains(leaf.element())) - { - leaf.setPlaceholder(false); - } - else - { - if (seqmatcher == null) - { - // Only create this the first time we need it - SequenceI[] seqs = new SequenceI[alignment.size()]; - - for (int j = 0; j < seqs.length; j++) - seqs[j] = (SequenceI) alignment.elementAt(j); - - seqmatcher = new SequenceIdMatcher(seqs); - } - - SequenceI nam = seqmatcher.findIdMatch(leaf.getName()); - - if (nam != null) - { - if (!leaf.isPlaceholder()) { - // remapping the node to a new sequenceI - should remove any refs to old one. - // TODO - make many sequenceI to one leaf mappings possible! (JBPNote) - } - leaf.setPlaceholder(false); - leaf.setElement(nam); - } - else - { - if (!leaf.isPlaceholder()) { - // Construct a new placeholder sequence object for this leaf - leaf.setElement(new Sequence(leaf.getName(), "THISISAPLACEHLDER")); - } - leaf.setPlaceholder(true); - - } - } - } - } + done = new int[sequence.length]; - /** - * DOCUMENT ME! - */ - public void cluster() + while ( (i < sequence.length) && (sequence[i] != null)) { - while (noClus > 2) - { - if (type.equals("NJ")) - { - findMinNJDistance(); - } - else - { - findMinDistance(); - } + done[i] = 0; + i++; + } - Cluster c = joinClusters(mini, minj); + noseqs = i++; - done[minj] = 1; + distance = findDistances(this.seqData.getSequenceStrings(Comparison. + GapChars.charAt(0))); - cluster.setElementAt(null, minj); - cluster.setElementAt(c, mini); + makeLeaves(); - noClus--; - } + noClus = cluster.size(); - boolean onefound = false; + cluster(); + } - int one = -1; - int two = -1; + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String toString() + { + jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode()); - for (int i = 0; i < noseqs; i++) - { - if (done[i] != 1) - { - if (onefound == false) - { - two = i; - onefound = true; - } - else - { - one = i; - } - } - } + return fout.print(false, true); // distances only + } - joinClusters(one, two); - top = (SequenceNode) (node.elementAt(one)); + /** + * + * used when the alignment associated to a tree has changed. + * + * @param alignment Vector + */ + public void UpdatePlaceHolders(Vector alignment) + { + Vector leaves = new Vector(); + findLeaves(top, leaves); - reCount(top); - findHeight(top); - findMaxDist(top); - } + int sz = leaves.size(); + SequenceIdMatcher seqmatcher = null; + int i = 0; - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - * @param j DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Cluster joinClusters(int i, int j) + while (i < sz) { - float dist = distance[i][j]; + SequenceNode leaf = (SequenceNode) leaves.elementAt(i++); - int noi = ((Cluster) cluster.elementAt(i)).value.length; - int noj = ((Cluster) cluster.elementAt(j)).value.length; - - int[] value = new int[noi + noj]; - - for (int ii = 0; ii < noi; ii++) + if (alignment.contains(leaf.element())) + { + leaf.setPlaceholder(false); + } + else + { + if (seqmatcher == null) { - value[ii] = ((Cluster) cluster.elementAt(i)).value[ii]; - } + // Only create this the first time we need it + SequenceI[] seqs = new SequenceI[alignment.size()]; - for (int ii = noi; ii < (noi + noj); ii++) - { - value[ii] = ((Cluster) cluster.elementAt(j)).value[ii - noi]; - } + for (int j = 0; j < seqs.length; j++) + { + seqs[j] = (SequenceI) alignment.elementAt(j); + } - Cluster c = new Cluster(value); + seqmatcher = new SequenceIdMatcher(seqs); + } - ri = findr(i, j); - rj = findr(j, i); + SequenceI nam = seqmatcher.findIdMatch(leaf.getName()); - if (type.equals("NJ")) + if (nam != null) { - findClusterNJDistance(i, j); + if (!leaf.isPlaceholder()) + { + // remapping the node to a new sequenceI - should remove any refs to old one. + // TODO - make many sequenceI to one leaf mappings possible! (JBPNote) + } + leaf.setPlaceholder(false); + leaf.setElement(nam); } else { - findClusterDistance(i, j); + if (!leaf.isPlaceholder()) + { + // Construct a new placeholder sequence object for this leaf + leaf.setElement(new Sequence(leaf.getName(), "THISISAPLACEHLDER")); + } + leaf.setPlaceholder(true); + } + } + } + } + + /** + * DOCUMENT ME! + */ + public void cluster() + { + while (noClus > 2) + { + if (type.equals("NJ")) + { + findMinNJDistance(); + } + else + { + findMinDistance(); + } + + Cluster c = joinClusters(mini, minj); + + done[minj] = 1; - SequenceNode sn = new SequenceNode(); + cluster.setElementAt(null, minj); + cluster.setElementAt(c, mini); - sn.setLeft((SequenceNode) (node.elementAt(i))); - sn.setRight((SequenceNode) (node.elementAt(j))); + noClus--; + } + + boolean onefound = false; - SequenceNode tmpi = (SequenceNode) (node.elementAt(i)); - SequenceNode tmpj = (SequenceNode) (node.elementAt(j)); + int one = -1; + int two = -1; - if (type.equals("NJ")) + for (int i = 0; i < noseqs; i++) + { + if (done[i] != 1) + { + if (onefound == false) { - findNewNJDistances(tmpi, tmpj, dist); + two = i; + onefound = true; } else { - findNewDistances(tmpi, tmpj, dist); + one = i; } + } + } + + joinClusters(one, two); + top = (SequenceNode) (node.elementAt(one)); + + reCount(top); + findHeight(top); + findMaxDist(top); + } + + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Cluster joinClusters(int i, int j) + { + float dist = distance[i][j]; - tmpi.setParent(sn); - tmpj.setParent(sn); + int noi = ( (Cluster) cluster.elementAt(i)).value.length; + int noj = ( (Cluster) cluster.elementAt(j)).value.length; - node.setElementAt(sn, i); + int[] value = new int[noi + noj]; - return c; + for (int ii = 0; ii < noi; ii++) + { + value[ii] = ( (Cluster) cluster.elementAt(i)).value[ii]; } - /** - * DOCUMENT ME! - * - * @param tmpi DOCUMENT ME! - * @param tmpj DOCUMENT ME! - * @param dist DOCUMENT ME! - */ - public void findNewNJDistances(SequenceNode tmpi, SequenceNode tmpj, - float dist) + for (int ii = noi; ii < (noi + noj); ii++) { + value[ii] = ( (Cluster) cluster.elementAt(j)).value[ii - noi]; + } - tmpi.dist = ((dist + ri) - rj) / 2; - tmpj.dist = (dist - tmpi.dist); + Cluster c = new Cluster(value); - if (tmpi.dist < 0) - { - tmpi.dist = 0; - } + ri = findr(i, j); + rj = findr(j, i); - if (tmpj.dist < 0) - { - tmpj.dist = 0; - } + if (type.equals("NJ")) + { + findClusterNJDistance(i, j); } - - /** - * DOCUMENT ME! - * - * @param tmpi DOCUMENT ME! - * @param tmpj DOCUMENT ME! - * @param dist DOCUMENT ME! - */ - public void findNewDistances(SequenceNode tmpi, SequenceNode tmpj, - float dist) + else { - float ih = 0; - float jh = 0; + findClusterDistance(i, j); + } - SequenceNode sni = tmpi; - SequenceNode snj = tmpj; + SequenceNode sn = new SequenceNode(); - while (sni != null) - { - ih = ih + sni.dist; - sni = (SequenceNode) sni.left(); - } + sn.setLeft( (SequenceNode) (node.elementAt(i))); + sn.setRight( (SequenceNode) (node.elementAt(j))); - while (snj != null) - { - jh = jh + snj.dist; - snj = (SequenceNode) snj.left(); - } + SequenceNode tmpi = (SequenceNode) (node.elementAt(i)); + SequenceNode tmpj = (SequenceNode) (node.elementAt(j)); - tmpi.dist = ((dist / 2) - ih); - tmpj.dist = ((dist / 2) - jh); + if (type.equals("NJ")) + { + findNewNJDistances(tmpi, tmpj, dist); } - - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - * @param j DOCUMENT ME! - */ - public void findClusterDistance(int i, int j) + else { - int noi = ((Cluster) cluster.elementAt(i)).value.length; - int noj = ((Cluster) cluster.elementAt(j)).value.length; + findNewDistances(tmpi, tmpj, dist); + } - // New distances from cluster to others - float[] newdist = new float[noseqs]; + tmpi.setParent(sn); + tmpj.setParent(sn); - for (int l = 0; l < noseqs; l++) - { - if ((l != i) && (l != j)) - { - newdist[l] = ((distance[i][l] * noi) + (distance[j][l] * noj)) / (noi + - noj); - } - else - { - newdist[l] = 0; - } - } + node.setElementAt(sn, i); - for (int ii = 0; ii < noseqs; ii++) - { - distance[i][ii] = newdist[ii]; - distance[ii][i] = newdist[ii]; - } + return c; + } + + /** + * DOCUMENT ME! + * + * @param tmpi DOCUMENT ME! + * @param tmpj DOCUMENT ME! + * @param dist DOCUMENT ME! + */ + public void findNewNJDistances(SequenceNode tmpi, SequenceNode tmpj, + float dist) + { + + tmpi.dist = ( (dist + ri) - rj) / 2; + tmpj.dist = (dist - tmpi.dist); + + if (tmpi.dist < 0) + { + tmpi.dist = 0; } - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - * @param j DOCUMENT ME! - */ - public void findClusterNJDistance(int i, int j) + if (tmpj.dist < 0) { + tmpj.dist = 0; + } + } - // New distances from cluster to others - float[] newdist = new float[noseqs]; + /** + * DOCUMENT ME! + * + * @param tmpi DOCUMENT ME! + * @param tmpj DOCUMENT ME! + * @param dist DOCUMENT ME! + */ + public void findNewDistances(SequenceNode tmpi, SequenceNode tmpj, + float dist) + { + float ih = 0; + float jh = 0; - for (int l = 0; l < noseqs; l++) - { - if ((l != i) && (l != j)) - { - newdist[l] = ((distance[i][l] + distance[j][l]) - - distance[i][j]) / 2; - } - else - { - newdist[l] = 0; - } - } + SequenceNode sni = tmpi; + SequenceNode snj = tmpj; - for (int ii = 0; ii < noseqs; ii++) - { - distance[i][ii] = newdist[ii]; - distance[ii][i] = newdist[ii]; - } + while (sni != null) + { + ih = ih + sni.dist; + sni = (SequenceNode) sni.left(); } - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - * @param j DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public float findr(int i, int j) + while (snj != null) { - float tmp = 1; + jh = jh + snj.dist; + snj = (SequenceNode) snj.left(); + } - for (int k = 0; k < noseqs; k++) - { - if ((k != i) && (k != j) && (done[k] != 1)) - { - tmp = tmp + distance[i][k]; - } - } + tmpi.dist = ( (dist / 2) - ih); + tmpj.dist = ( (dist / 2) - jh); + } - if (noClus > 2) - { - tmp = tmp / (noClus - 2); - } + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + */ + public void findClusterDistance(int i, int j) + { + int noi = ( (Cluster) cluster.elementAt(i)).value.length; + int noj = ( (Cluster) cluster.elementAt(j)).value.length; - return tmp; + // New distances from cluster to others + float[] newdist = new float[noseqs]; + + for (int l = 0; l < noseqs; l++) + { + if ( (l != i) && (l != j)) + { + newdist[l] = ( (distance[i][l] * noi) + (distance[j][l] * noj)) / (noi + + noj); + } + else + { + newdist[l] = 0; + } } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public float findMinNJDistance() + for (int ii = 0; ii < noseqs; ii++) { - float min = 100000; + distance[i][ii] = newdist[ii]; + distance[ii][i] = newdist[ii]; + } + } - for (int i = 0; i < (noseqs - 1); i++) - { - for (int j = i + 1; j < noseqs; j++) - { - if ((done[i] != 1) && (done[j] != 1)) - { - float tmp = distance[i][j] - (findr(i, j) + findr(j, i)); - - if (tmp < min) - { - mini = i; - minj = j; - - min = tmp; - } - } - } - } + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + */ + public void findClusterNJDistance(int i, int j) + { - return min; + // New distances from cluster to others + float[] newdist = new float[noseqs]; + + for (int l = 0; l < noseqs; l++) + { + if ( (l != i) && (l != j)) + { + newdist[l] = ( (distance[i][l] + distance[j][l]) - + distance[i][j]) / 2; + } + else + { + newdist[l] = 0; + } } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public float findMinDistance() + for (int ii = 0; ii < noseqs; ii++) { - float min = 100000; + distance[i][ii] = newdist[ii]; + distance[ii][i] = newdist[ii]; + } + } - for (int i = 0; i < (noseqs - 1); i++) - { - for (int j = i + 1; j < noseqs; j++) - { - if ((done[i] != 1) && (done[j] != 1)) - { - if (distance[i][j] < min) - { - mini = i; - minj = j; - - min = distance[i][j]; - } - } - } - } + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findr(int i, int j) + { + float tmp = 1; - return min; + for (int k = 0; k < noseqs; k++) + { + if ( (k != i) && (k != j) && (done[k] != 1)) + { + tmp = tmp + distance[i][k]; + } } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public float[][] findDistances(String[] sequenceString) + if (noClus > 2) { - float[][] distance = new float[noseqs][noseqs]; + tmp = tmp / (noClus - 2); + } + + return tmp; + } - if (pwtype.equals("PID")) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findMinNJDistance() + { + float min = 100000; + + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i + 1; j < noseqs; j++) + { + if ( (done[i] != 1) && (done[j] != 1)) { - for (int i = 0; i < (noseqs - 1); i++) - { - for (int j = i; j < noseqs; j++) - { - if (j == i) - { - distance[i][i] = 0; - } - else - { - distance[i][j] = 100 - - Comparison.PID(sequenceString[i], sequenceString[j]); - - distance[j][i] = distance[i][j]; - } - } - } + float tmp = distance[i][j] - (findr(i, j) + findr(j, i)); + + if (tmp < min) + { + mini = i; + minj = j; + + min = tmp; + } } - else { - // Pairwise substitution score (with no gap penalties) - ScoreMatrix pwmatrix=ResidueProperties.getScoreMatrix(pwtype); - if (pwmatrix==null) { - pwmatrix=ResidueProperties.getScoreMatrix("BLOSUM62"); + } + } + + return min; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findMinDistance() + { + float min = 100000; + + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i + 1; j < noseqs; j++) + { + if ( (done[i] != 1) && (done[j] != 1)) + { + if (distance[i][j] < min) + { + mini = i; + minj = j; + + min = distance[i][j]; } - int maxscore = 0; - int end = sequenceString[0].length(); - for (int i = 0; i < (noseqs - 1); i++) + } + } + } + + return min; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float[][] findDistances(String[] sequenceString) + { + float[][] distance = new float[noseqs][noseqs]; + + if (pwtype.equals("PID")) + { + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) + { + if (j == i) { - for (int j = i; j < noseqs; j++) - { - int score = 0; - - for (int k = 0; k < end; k++) - { - try - { - score += pwmatrix.getPairwiseScore(sequenceString[i].charAt(k), - sequenceString[j].charAt(k)); - } - catch (Exception ex) - { - System.err.println("err creating BLOSUM62 tree"); - ex.printStackTrace(); - } - } - - distance[i][j] = (float) score; - - if (score > maxscore) - { - maxscore = score; - } - } + distance[i][i] = 0; } - - for (int i = 0; i < (noseqs - 1); i++) + else { - for (int j = i; j < noseqs; j++) - { - distance[i][j] = (float) maxscore - distance[i][j]; - distance[j][i] = distance[i][j]; - } + distance[i][j] = 100 - + Comparison.PID(sequenceString[i], sequenceString[j]); + + distance[j][i] = distance[i][j]; } - } - return distance; - - // else - /* else if (pwtype.equals("SW")) + } + } + else + { + // Pairwise substitution score (with no gap penalties) + ScoreMatrix pwmatrix = ResidueProperties.getScoreMatrix(pwtype); + if (pwmatrix == null) + { + pwmatrix = ResidueProperties.getScoreMatrix("BLOSUM62"); + } + int maxscore = 0; + int end = sequenceString[0].length(); + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) { - float max = -1; + int score = 0; - for (int i = 0; i < (noseqs - 1); i++) + for (int k = 0; k < end; k++) + { + try { - for (int j = i; j < noseqs; j++) - { - AlignSeq as = new AlignSeq(sequence[i], sequence[j], "pep"); - as.calcScoreMatrix(); - as.traceAlignment(); - as.printAlignment(System.out); - distance[i][j] = (float) as.maxscore; - - if (max < distance[i][j]) - { - max = distance[i][j]; - } - } + score += pwmatrix.getPairwiseScore(sequenceString[i].charAt(k), + sequenceString[j].charAt(k)); } - - for (int i = 0; i < (noseqs - 1); i++) + catch (Exception ex) { - for (int j = i; j < noseqs; j++) - { - distance[i][j] = max - distance[i][j]; - distance[j][i] = distance[i][j]; - } + System.err.println("err creating BLOSUM62 tree"); + ex.printStackTrace(); } - }/*/ - } + } - /** - * DOCUMENT ME! - */ - public void makeLeaves() - { - cluster = new Vector(); + distance[i][j] = (float) score; - for (int i = 0; i < noseqs; i++) + if (score > maxscore) + { + maxscore = score; + } + } + } + + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) { - SequenceNode sn = new SequenceNode(); + distance[i][j] = (float) maxscore - distance[i][j]; + distance[j][i] = distance[i][j]; + } + } - sn.setElement(sequence[i]); - sn.setName(sequence[i].getName()); - node.addElement(sn); + } + return distance; - int[] value = new int[1]; - value[0] = i; + // else + /* else if (pwtype.equals("SW")) + { + float max = -1; - Cluster c = new Cluster(value); - cluster.addElement(c); - } - } + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) + { + AlignSeq as = new AlignSeq(sequence[i], sequence[j], "pep"); + as.calcScoreMatrix(); + as.traceAlignment(); + as.printAlignment(System.out); + distance[i][j] = (float) as.maxscore; + + if (max < distance[i][j]) + { + max = distance[i][j]; + } + } + } - /** - * DOCUMENT ME! - * - * @param node DOCUMENT ME! - * @param leaves DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Vector findLeaves(SequenceNode node, Vector leaves) + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) + { + distance[i][j] = max - distance[i][j]; + distance[j][i] = distance[i][j]; + } + } + }/*/ + } + + /** + * DOCUMENT ME! + */ + public void makeLeaves() + { + cluster = new Vector(); + + for (int i = 0; i < noseqs; i++) { - if (node == null) - { - return leaves; - } + SequenceNode sn = new SequenceNode(); - if ((node.left() == null) && (node.right() == null)) - { - leaves.addElement(node); + sn.setElement(sequence[i]); + sn.setName(sequence[i].getName()); + node.addElement(sn); - return leaves; - } - else - { - findLeaves((SequenceNode) node.left(), leaves); - findLeaves((SequenceNode) node.right(), leaves); - } + int[] value = new int[1]; + value[0] = i; - return leaves; + Cluster c = new Cluster(value); + cluster.addElement(c); } + } - /** - * DOCUMENT ME! - * - * @param node DOCUMENT ME! - * @param count DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Object findLeaf(SequenceNode node, int count) + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param leaves DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector findLeaves(SequenceNode node, Vector leaves) + { + if (node == null) { - found = _findLeaf(node, count); - - return found; + return leaves; } - /** - * DOCUMENT ME! - * - * @param node DOCUMENT ME! - * @param count DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Object _findLeaf(SequenceNode node, int count) + if ( (node.left() == null) && (node.right() == null)) { - if (node == null) - { - return null; - } + leaves.addElement(node); - if (node.ycount == count) - { - found = node.element(); + return leaves; + } + else + { + findLeaves( (SequenceNode) node.left(), leaves); + findLeaves( (SequenceNode) node.right(), leaves); + } - return found; - } - else - { - _findLeaf((SequenceNode) node.left(), count); - _findLeaf((SequenceNode) node.right(), count); - } + return leaves; + } + + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param count DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Object findLeaf(SequenceNode node, int count) + { + found = _findLeaf(node, count); + + return found; + } - return found; + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param count DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Object _findLeaf(SequenceNode node, int count) + { + if (node == null) + { + return null; } - /** - * printNode is mainly for debugging purposes. - * - * @param node SequenceNode - */ - public void printNode(SequenceNode node) + if (node.ycount == count) { - if (node == null) - { - return; - } + found = node.element(); - if ((node.left() == null) && (node.right() == null)) - { - System.out.println("Leaf = " + - ((SequenceI) node.element()).getName()); - System.out.println("Dist " + ((SequenceNode) node).dist); - System.out.println("Boot " + node.getBootstrap()); - } - else - { - System.out.println("Dist " + ((SequenceNode) node).dist); - printNode((SequenceNode) node.left()); - printNode((SequenceNode) node.right()); - } + return found; } - - /** - * DOCUMENT ME! - * - * @param node DOCUMENT ME! - */ - public void findMaxDist(SequenceNode node) + else { - if (node == null) - { - return; - } + _findLeaf( (SequenceNode) node.left(), count); + _findLeaf( (SequenceNode) node.right(), count); + } - if ((node.left() == null) && (node.right() == null)) - { - float dist = ((SequenceNode) node).dist; + return found; + } - if (dist > maxDistValue) - { - maxdist = (SequenceNode) node; - maxDistValue = dist; - } - } - else - { - findMaxDist((SequenceNode) node.left()); - findMaxDist((SequenceNode) node.right()); - } + /** + * printNode is mainly for debugging purposes. + * + * @param node SequenceNode + */ + public void printNode(SequenceNode node) + { + if (node == null) + { + return; } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Vector getGroups() + if ( (node.left() == null) && (node.right() == null)) { - return groups; + System.out.println("Leaf = " + + ( (SequenceI) node.element()).getName()); + System.out.println("Dist " + ( (SequenceNode) node).dist); + System.out.println("Boot " + node.getBootstrap()); } + else + { + System.out.println("Dist " + ( (SequenceNode) node).dist); + printNode( (SequenceNode) node.left()); + printNode( (SequenceNode) node.right()); + } + } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public float getMaxHeight() + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + */ + public void findMaxDist(SequenceNode node) + { + if (node == null) { - return maxheight; + return; } - /** - * DOCUMENT ME! - * - * @param node DOCUMENT ME! - * @param threshold DOCUMENT ME! - */ - public void groupNodes(SequenceNode node, float threshold) + if ( (node.left() == null) && (node.right() == null)) { - if (node == null) - { - return; - } + float dist = ( (SequenceNode) node).dist; - if ((node.height / maxheight) > threshold) - { - groups.addElement(node); - } - else - { - groupNodes((SequenceNode) node.left(), threshold); - groupNodes((SequenceNode) node.right(), threshold); - } + if (dist > maxDistValue) + { + maxdist = (SequenceNode) node; + maxDistValue = dist; + } + } + else + { + findMaxDist( (SequenceNode) node.left()); + findMaxDist( (SequenceNode) node.right()); } + } - /** - * DOCUMENT ME! - * - * @param node DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public float findHeight(SequenceNode node) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector getGroups() + { + return groups; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float getMaxHeight() + { + return maxheight; + } + + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param threshold DOCUMENT ME! + */ + public void groupNodes(SequenceNode node, float threshold) + { + if (node == null) { - if (node == null) - { - return maxheight; - } + return; + } - if ((node.left() == null) && (node.right() == null)) - { - node.height = ((SequenceNode) node.parent()).height + node.dist; + if ( (node.height / maxheight) > threshold) + { + groups.addElement(node); + } + else + { + groupNodes( (SequenceNode) node.left(), threshold); + groupNodes( (SequenceNode) node.right(), threshold); + } + } - if (node.height > maxheight) - { - return node.height; - } - else - { - return maxheight; - } - } - else - { - if (node.parent() != null) - { - node.height = ((SequenceNode) node.parent()).height + - node.dist; - } - else - { - maxheight = 0; - node.height = (float) 0.0; - } + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findHeight(SequenceNode node) + { + if (node == null) + { + return maxheight; + } - maxheight = findHeight((SequenceNode) (node.left())); - maxheight = findHeight((SequenceNode) (node.right())); - } + if ( (node.left() == null) && (node.right() == null)) + { + node.height = ( (SequenceNode) node.parent()).height + node.dist; + if (node.height > maxheight) + { + return node.height; + } + else + { return maxheight; + } } + else + { + if (node.parent() != null) + { + node.height = ( (SequenceNode) node.parent()).height + + node.dist; + } + else + { + maxheight = 0; + node.height = (float) 0.0; + } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public SequenceNode reRoot() + maxheight = findHeight( (SequenceNode) (node.left())); + maxheight = findHeight( (SequenceNode) (node.right())); + } + + return maxheight; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceNode reRoot() + { + if (maxdist != null) { - if (maxdist != null) - { - ycount = 0; + ycount = 0; - float tmpdist = maxdist.dist; + float tmpdist = maxdist.dist; - // New top - SequenceNode sn = new SequenceNode(); - sn.setParent(null); + // New top + SequenceNode sn = new SequenceNode(); + sn.setParent(null); - // New right hand of top - SequenceNode snr = (SequenceNode) maxdist.parent(); - changeDirection(snr, maxdist); - System.out.println("Printing reversed tree"); - printN(snr); - snr.dist = tmpdist / 2; - maxdist.dist = tmpdist / 2; + // New right hand of top + SequenceNode snr = (SequenceNode) maxdist.parent(); + changeDirection(snr, maxdist); + System.out.println("Printing reversed tree"); + printN(snr); + snr.dist = tmpdist / 2; + maxdist.dist = tmpdist / 2; - snr.setParent(sn); - maxdist.setParent(sn); + snr.setParent(sn); + maxdist.setParent(sn); - sn.setRight(snr); - sn.setLeft(maxdist); + sn.setRight(snr); + sn.setLeft(maxdist); - top = sn; + top = sn; - ycount = 0; - reCount(top); - findHeight(top); - } + ycount = 0; + reCount(top); + findHeight(top); + } - return top; + return top; + } + + /** + * + * @return true if original sequence data can be recovered + */ + public boolean hasOriginalSequenceData() + { + return seqData != null; + } + + /** + * Returns original alignment data used for calculation - or null where + * not available. + * + * @return null or cut'n'pasteable alignment + */ + public String printOriginalSequenceData(char gapChar) + { + if (seqData == null) + { + return null; } - /** - * - * @return true if original sequence data can be recovered - */ - public boolean hasOriginalSequenceData() { - return seqData!=null; + + StringBuffer sb = new StringBuffer(); + String[] seqdatas = seqData.getSequenceStrings(gapChar); + for (int i = 0; i < seqdatas.length; i++) + { + sb.append(new jalview.util.Format("%-" + 15 + "s").form( + sequence[i].getName())); + sb.append(" " + seqdatas[i] + "\n"); } - /** - * Returns original alignment data used for calculation - or null where - * not available. - * - * @return null or cut'n'pasteable alignment - */ - public String printOriginalSequenceData(char gapChar) + return sb.toString(); + } + + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + */ + public void printN(SequenceNode node) + { + if (node == null) { - if (seqData==null) - return null; + return; + } - StringBuffer sb = new StringBuffer(); - String[] seqdatas = seqData.getSequenceStrings(gapChar); - for(int i=0; i0) { - for (int i=0;i 0) + { + for (int i = 0; i < sfarray.length; i++) + { sfeat.add(sfarray[i]); + } } sqinfo.put("SeqFeatures", sfeat); sqinfo.put("PdbId", (seq.getPDBId() != null) ? seq.getPDBId() : new Vector()); - sqinfo.put("datasetSequence", (seq.getDatasetSequence() !=null) ? seq.getDatasetSequence() : new Sequence("THISISAPLACEHOLDER","")); + sqinfo.put("datasetSequence", + (seq.getDatasetSequence() != null) ? seq.getDatasetSequence() : + new Sequence("THISISAPLACEHOLDER", "")); return sqinfo; } @@ -74,15 +81,17 @@ public class SeqsetUtils public static boolean SeqCharacterUnhash(SequenceI sq, Hashtable sqinfo) { boolean namePresent = true; - if (sqinfo==null) + if (sqinfo == null) + { return false; + } String oldname = (String) sqinfo.get("Name"); Integer start = (Integer) sqinfo.get("Start"); Integer end = (Integer) sqinfo.get("End"); Vector sfeatures = (Vector) sqinfo.get( "SeqFeatures"); Vector pdbid = (Vector) sqinfo.get("PdbId"); - String description=(String) sqinfo.get("Description"); + String description = (String) sqinfo.get("Description"); Sequence seqds = (Sequence) sqinfo.get("datasetSequence"); if (oldname == null) { @@ -92,7 +101,7 @@ public class SeqsetUtils { sq.setName(oldname); } - if (pdbid!=null && pdbid.size()>0) + if (pdbid != null && pdbid.size() > 0) { sq.setPDBId(pdbid); } @@ -103,14 +112,19 @@ public class SeqsetUtils sq.setEnd(end.intValue()); } - if ((sfeatures != null) && (sfeatures.size()>0)) + if ( (sfeatures != null) && (sfeatures.size() > 0)) { SequenceFeature[] sfarray = (SequenceFeature[]) sfeatures.toArray(); sq.setSequenceFeatures(sfarray); } - if (description!=null) + if (description != null) + { sq.setDescription(description); - if ((seqds!=null) && !(seqds.getName().equals("THISISAPLACEHOLDER") && seqds.getLength()==0)) { + } + if ( (seqds != null) && + ! (seqds.getName().equals("THISISAPLACEHOLDER") && + seqds.getLength() == 0)) + { sq.setDatasetSequence(seqds); } @@ -152,9 +166,9 @@ public class SeqsetUtils } } - return map; } + /** * recover unsafe sequence names and original properties for a sequence * set using a map generated by @see uniquify(sequences,true) @@ -164,66 +178,88 @@ public class SeqsetUtils */ public static boolean deuniquify(Hashtable map, SequenceI[] sequences) { - jalview.analysis.SequenceIdMatcher matcher = new SequenceIdMatcher(sequences); + jalview.analysis.SequenceIdMatcher matcher = new SequenceIdMatcher( + sequences); SequenceI msq = null; Enumeration keys = map.keys(); Vector unmatched = new Vector(); - for (int i=0, j=sequences.length; i0) { + if (unmatched.size() > 0) + { System.err.println("Did not find matches for :"); - for (Enumeration i = unmatched.elements(); i.hasMoreElements(); System.out.println(((SequenceI) i.nextElement()).getName())) - ; + for (Enumeration i = unmatched.elements(); i.hasMoreElements(); + System.out.println( ( (SequenceI) i.nextElement()).getName())) + { + ; + } return false; } return true; } + /** * returns a subset of the sequenceI seuqences, * including only those that contain at least one residue. * @param sequences SequenceI[] * @return SequenceI[] */ - public static SequenceI[] getNonEmptySequenceSet(SequenceI[] sequences) { - // Identify first row of alignment with residues for prediction - boolean ungapped[] = new boolean[sequences.length]; - int msflen=0; - for (int i=0,j=sequences.length; i0) { + int matchlen = match.getName().length(); + int namlen = candName.id.length(); + while (matches.size() > 0) + { // look through for a better one. - SequenceI cand=(SequenceI) matches.elementAt(0); + SequenceI cand = (SequenceI) matches.elementAt(0); names.put(new SeqIdName(cand.getName()), cand); int candlen = cand.getName().length(); // keep the one with an id 'closer' to the given seqnam string - if (Math.abs(matchlen-namlen)>Math.abs(candlen-namlen) && candlen>matchlen) { + if (Math.abs(matchlen - namlen) > Math.abs(candlen - namlen) && + candlen > matchlen) + { match = cand; matchlen = candlen; } @@ -91,10 +98,11 @@ public class SequenceIdMatcher } SequenceI findIdMatch(String seqnam) - { - SeqIdName nam = new SeqIdName(seqnam); - return findIdMatch(nam); + { + SeqIdName nam = new SeqIdName(seqnam); + return findIdMatch(nam); } + /** * findIdMatch * @@ -140,7 +148,7 @@ public class SequenceIdMatcher private SequenceI findIdMatch(jalview.analysis.SequenceIdMatcher.SeqIdName nam) { - Vector matches=new Vector(); + Vector matches = new Vector(); while (names.containsKey(nam)) { matches.addElement(names.remove(nam)); @@ -154,15 +162,19 @@ public class SequenceIdMatcher SeqIdName(String s) { - if (s!=null) + if (s != null) + { id = new String(s); + } else + { id = ""; + } } public int hashCode() { - return ((id.length()>=4) ? id.substring(0, 4).hashCode() : id.hashCode()); + return ( (id.length() >= 4) ? id.substring(0, 4).hashCode() : id.hashCode()); } public boolean equals(Object s) @@ -188,39 +200,47 @@ public class SequenceIdMatcher * JBPNote: This is a heuristic that will fail for arbritrarily extended sequence id's * (like portions of an aligned set of repeats from one sequence) */ - private String WORD_SEP="~. |#\\/<>!\"£$%^*)}[@',?_"; - - /** - * matches if one ID properly contains another at a whitespace boundary. - * TODO: (JBPNote) These are not efficient. should use char[] for speed - * todo: (JBPNote) Set separator characters appropriately - * @param s SeqIdName - * @return boolean - */ + private String WORD_SEP = "~. |#\\/<>!\"£$%^*)}[@',?_"; + + /** + * matches if one ID properly contains another at a whitespace boundary. + * TODO: (JBPNote) These are not efficient. should use char[] for speed + * todo: (JBPNote) Set separator characters appropriately + * @param s SeqIdName + * @return boolean + */ public boolean equals(SeqIdName s) { - if (id.length()>s.id.length()) { + if (id.length() > s.id.length()) + { return id.startsWith(s.id) ? - (WORD_SEP.indexOf(id.charAt(s.id.length()))>-1) + (WORD_SEP.indexOf(id.charAt(s.id.length())) > -1) : false; - } else + } + else + { return s.id.startsWith(id) ? (s.id.equals(id) ? true : - (WORD_SEP.indexOf(s.id.charAt(id.length()))>-1)) + (WORD_SEP.indexOf(s.id.charAt(id.length())) > -1)) : false; + } } public boolean equals(String s) { - if (id.length()>s.length()) { + if (id.length() > s.length()) + { return id.startsWith(s) ? - (WORD_SEP.indexOf(id.charAt(s.length()))>-1) + (WORD_SEP.indexOf(id.charAt(s.length())) > -1) : false; - } else + } + else + { return s.startsWith(id) ? (s.equals(id) ? true : - (WORD_SEP.indexOf(s.charAt(id.length()))>-1)) + (WORD_SEP.indexOf(s.charAt(id.length())) > -1)) : false; + } } } } diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 5f73fbf..fde6bb8 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -19,14 +19,15 @@ package jalview.appletgui; +import java.util.*; + import java.awt.*; import java.awt.event.*; -import java.util.Vector; import jalview.analysis.*; +import jalview.commands.*; import jalview.datamodel.*; import jalview.schemes.*; -import jalview.commands.ChangeCaseCommand; public class APopupMenu extends java.awt.PopupMenu implements ActionListener, ItemListener @@ -93,9 +94,11 @@ public class APopupMenu e.printStackTrace(); } - for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) + for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; + i++) { - MenuItem item = new MenuItem( jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i] ); + MenuItem item = new MenuItem(jalview.io.AppletFormatAdapter. + WRITEABLE_FORMATS[i]); item.addActionListener(this); outputmenu.add(item); @@ -103,7 +106,7 @@ public class APopupMenu SequenceGroup sg = ap.av.getSelectionGroup(); - if (sg != null && sg.getSize()>0) + if (sg != null && sg.getSize() > 0) { editGroupName.setLabel(sg.getName()); showText.setState(sg.getDisplayText()); @@ -121,12 +124,12 @@ public class APopupMenu remove(groupMenu); } - if (links!=null) + if (links != null) { Menu linkMenu = new Menu("Link"); MenuItem item; String link; - for(int i=0; i -1) + { id = id.substring(id.lastIndexOf("|") + 1); + } url = link.substring(link.indexOf("|") + 1, link.indexOf("$SEQUENCE_ID$")) @@ -146,95 +151,151 @@ public class APopupMenu link.substring(link.indexOf("$SEQUENCE_ID$") + 13); } else - url = link.substring(link.lastIndexOf("|")+1); - - item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - ap.alignFrame.showURL(url, target); - } - }); - linkMenu.add(item); + { + url = link.substring(link.lastIndexOf("|") + 1); + } + + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + ap.alignFrame.showURL(url, target); + } + }); + linkMenu.add(item); } - if(seq!=null) + if (seq != null) + { seqMenu.add(linkMenu); + } else + { add(linkMenu); + } } - if(seq!=null) + if (seq != null) { seqMenu.setLabel(seq.getName()); repGroup.setLabel("Represent Group with " + seq.getName()); } else + { remove(seqMenu); + } - if(!ap.av.hasHiddenRows) + if (!ap.av.hasHiddenRows) + { remove(revealAll); + } } public void itemStateChanged(ItemEvent evt) { - if(evt.getSource()==abovePIDColour) + if (evt.getSource() == abovePIDColour) + { abovePIDColour_itemStateChanged(); - else if(evt.getSource()==showColourText) + } + else if (evt.getSource() == showColourText) + { showColourText_itemStateChanged(); - else if(evt.getSource()==showText) + } + else if (evt.getSource() == showText) + { showText_itemStateChanged(); - else if(evt.getSource()==showBoxes) - showBoxes_itemStateChanged() ; + } + else if (evt.getSource() == showBoxes) + { + showBoxes_itemStateChanged(); + } } public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); - if(source==clustalColour) + if (source == clustalColour) + { clustalColour_actionPerformed(); - else if(source==zappoColour) + } + else if (source == zappoColour) + { zappoColour_actionPerformed(); - else if(source==taylorColour) + } + else if (source == taylorColour) + { taylorColour_actionPerformed(); - else if(source==hydrophobicityColour) + } + else if (source == hydrophobicityColour) + { hydrophobicityColour_actionPerformed(); - else if(source==helixColour) + } + else if (source == helixColour) + { helixColour_actionPerformed(); - else if(source==strandColour) + } + else if (source == strandColour) + { strandColour_actionPerformed(); - else if(source==turnColour) + } + else if (source == turnColour) + { turnColour_actionPerformed(); - else if(source==buriedColour) + } + else if (source == buriedColour) + { buriedColour_actionPerformed(); - else if(source==nucleotideMenuItem) + } + else if (source == nucleotideMenuItem) + { nucleotideMenuItem_actionPerformed(); + } else if (source == userDefinedColour) + { userDefinedColour_actionPerformed(); + } else if (source == PIDColour) + { PIDColour_actionPerformed(); + } else if (source == BLOSUM62Colour) + { BLOSUM62Colour_actionPerformed(); + } else if (source == noColourmenuItem) + { noColourmenuItem_actionPerformed(); + } else if (source == conservationMenuItem) + { conservationMenuItem_itemStateChanged(); + } else if (source == unGroupMenuItem) + { unGroupMenuItem_actionPerformed(); + } - else if(source == sequenceName) + else if (source == sequenceName) + { editName(); - else if(source == pdb) + } + else if (source == pdb) + { addPDB(); - else if(source == hideSeqs) + } + else if (source == hideSeqs) + { hideSequences(false); - else if(source == repGroup) + } + else if (source == repGroup) + { hideSequences(true); - else if(source == revealAll) + } + else if (source == revealAll) { - ap.av.showAllHiddenSeqs(); + ap.av.showAllHiddenSeqs(); } - else if(source==editGroupName) + else if (source == editGroupName) { EditNameDialog dialog = new EditNameDialog( getGroup().getName(), @@ -252,84 +313,95 @@ public class APopupMenu } } - else if(source==copy) + else if (source == copy) + { ap.alignFrame.copy_actionPerformed(); - else if(source==cut) - ap.alignFrame.cut_actionPerformed(); - else if(source==toUpper || source==toLower || source==toggleCase) + } + else if (source == cut) { - SequenceGroup sg = ap.av.getSelectionGroup(); - Vector regions = new Vector(); - if (sg != null) + ap.alignFrame.cut_actionPerformed(); + } + else if (source == toUpper || source == toLower || source == toggleCase) { - int start = sg.getStartRes(); - int end = sg.getEndRes() + 1; - - do + SequenceGroup sg = ap.av.getSelectionGroup(); + Vector regions = new Vector(); + if (sg != null) { - if (ap.av.hasHiddenColumns) + int start = sg.getStartRes(); + int end = sg.getEndRes() + 1; + + do { - if(start==0) - start = ap.av.colSel.adjustForHiddenColumns(start); - - end = ap.av.colSel.getHiddenBoundaryRight(start); - if (start == end) - end = sg.getEndRes() + 1; - if (end > sg.getEndRes()) - end = sg.getEndRes() + 1; + if (ap.av.hasHiddenColumns) + { + if (start == 0) + { + start = ap.av.colSel.adjustForHiddenColumns(start); + } + + end = ap.av.colSel.getHiddenBoundaryRight(start); + if (start == end) + { + end = sg.getEndRes() + 1; + } + if (end > sg.getEndRes()) + { + end = sg.getEndRes() + 1; + } + } + + regions.addElement(new int[] + {start, end}); + + if (ap.av.hasHiddenColumns) + { + start = ap.av.colSel.adjustForHiddenColumns(end); + start = ap.av.colSel.getHiddenBoundaryLeft(start) + 1; + } } + while (end < sg.getEndRes()); - regions.addElement(new int[] - {start, end}); - - if (ap.av.hasHiddenColumns) + int[][] startEnd = new int[regions.size()][2]; + for (int i = 0; i < regions.size(); i++) { - start = ap.av.colSel.adjustForHiddenColumns(end); - start = ap.av.colSel.getHiddenBoundaryLeft(start) + 1; + startEnd[i] = (int[]) regions.elementAt(i); } - } - while (end < sg.getEndRes()); - int[][] startEnd = new int[regions.size()][2]; - for (int i = 0; i < regions.size(); i++) - { - startEnd[i] = (int[]) regions.elementAt(i); - } + String description; + int caseChange; + if (source == toggleCase) + { + description = "Toggle Case"; + caseChange = ChangeCaseCommand.TOGGLE_CASE; + } + else if (source == toUpper) + { + description = "To Upper Case"; + caseChange = ChangeCaseCommand.TO_UPPER; + } + else + { + description = "To Lower Case"; + caseChange = ChangeCaseCommand.TO_LOWER; + } - String description; - int caseChange; - - if(source==toggleCase) - { - description = "Toggle Case"; - caseChange = ChangeCaseCommand.TOGGLE_CASE; - } - else if(source==toUpper) - { - description = "To Upper Case"; - caseChange = ChangeCaseCommand.TO_UPPER; - } - else - { - description = "To Lower Case"; - caseChange = ChangeCaseCommand.TO_LOWER; - } - - ChangeCaseCommand caseCommand = new ChangeCaseCommand( - description, sg.getSequencesAsArray(ap.av.hiddenRepSequences), startEnd, caseChange - ); - - ap.alignFrame.addHistoryItem(caseCommand); + ChangeCaseCommand caseCommand = new ChangeCaseCommand( + description, sg.getSequencesAsArray(ap.av.hiddenRepSequences), + startEnd, caseChange + ); + ap.alignFrame.addHistoryItem(caseCommand); - ap.av.firePropertyChange("alignment", null, - ap.av.getAlignment().getSequences()); + ap.av.firePropertyChange("alignment", null, + ap.av.getAlignment().getSequences()); - } + } } else + { outputText(evt); + } } @@ -345,7 +417,7 @@ public class APopupMenu cap.setText(new jalview.io.AppletFormatAdapter().formatSequences( e.getActionCommand(), - new Alignment( ap.av.getSelectionAsNewSequence() ), + new Alignment(ap.av.getSelectionAsNewSequence()), ap.av.showJVSuffix)); } @@ -490,8 +562,10 @@ public class APopupMenu void refresh() { ap.seqPanel.seqCanvas.repaint(); - if(ap.overviewPanel!=null) + if (ap.overviewPanel != null) + { ap.overviewPanel.updateOverviewImage(); + } } protected void clustalColour_actionPerformed() @@ -553,12 +627,15 @@ public class APopupMenu protected void abovePIDColour_itemStateChanged() { SequenceGroup sg = getGroup(); - if(sg.cs==null) - return; + if (sg.cs == null) + { + return; + } if (abovePIDColour.getState()) { - sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.hiddenRepSequences), 0, + sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av. + hiddenRepSequences), 0, ap.av.alignment.getWidth())); int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup().getName()); @@ -586,7 +663,8 @@ public class APopupMenu { SequenceGroup sg = getGroup(); sg.cs = new PIDColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.hiddenRepSequences), 0, + sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av. + hiddenRepSequences), 0, ap.av.alignment.getWidth())); refresh(); } @@ -597,7 +675,8 @@ public class APopupMenu sg.cs = new Blosum62ColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.hiddenRepSequences), 0, + sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av. + hiddenRepSequences), 0, ap.av.alignment.getWidth())); refresh(); @@ -612,15 +691,18 @@ public class APopupMenu protected void conservationMenuItem_itemStateChanged() { SequenceGroup sg = getGroup(); - if(sg.cs==null) - return; + if (sg.cs == null) + { + return; + } if (conservationMenuItem.getState()) { Conservation c = new Conservation("Group", ResidueProperties.propHash, 3, - sg.getSequences(ap.av.hiddenRepSequences), 0, + sg.getSequences(ap.av. + hiddenRepSequences), 0, ap.av.alignment.getWidth()); c.calculate(); @@ -639,14 +721,15 @@ public class APopupMenu refresh(); } - SequenceGroup getGroup() { SequenceGroup sg = ap.av.getSelectionGroup(); // this method won't add a new group if it already exists - if(sg!=null) + if (sg != null) + { ap.av.alignment.addGroup(sg); + } return sg; } @@ -680,9 +763,10 @@ public class APopupMenu void hideSequences(boolean representGroup) { SequenceGroup sg = ap.av.getSelectionGroup(); - if(sg==null || sg.getSize()<1) + if (sg == null || sg.getSize() < 1) { - ap.av.hideSequence(new SequenceI[]{seq}); + ap.av.hideSequence(new SequenceI[] + {seq}); return; } @@ -707,6 +791,6 @@ public class APopupMenu } ap.av.hideSequence(hseqs); - } + } } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index de9da9f..a076345 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -19,20 +19,21 @@ package jalview.appletgui; -import jalview.schemes.*; -import jalview.datamodel.*; -import jalview.analysis.*; -import jalview.io.*; -import jalview.commands.*; +import java.io.*; +import java.net.*; +import java.util.*; + import java.awt.*; import java.awt.event.*; -import java.util.*; -import java.io.InputStreamReader; -import java.io.BufferedReader; -import java.net.URL; +import jalview.analysis.*; +import jalview.commands.*; +import jalview.datamodel.*; +import jalview.io.*; +import jalview.schemes.*; -public class AlignFrame extends Frame implements ActionListener, +public class AlignFrame + extends Frame implements ActionListener, ItemListener, KeyListener, MouseListener { public AlignmentPanel alignPanel; @@ -42,19 +43,22 @@ public class AlignFrame extends Frame implements ActionListener, String jalviewServletURL; - - public AlignFrame(AlignmentI al, - jalview.bin.JalviewLite applet, - String title, - boolean embedded) + public AlignFrame(AlignmentI al, + jalview.bin.JalviewLite applet, + String title, + boolean embedded) { if (applet != null) + { jalviewServletURL = applet.getParameter("APPLICATION_URL"); + } - try{ + try + { jbInit(); - }catch(Exception ex) + } + catch (Exception ex) { ex.printStackTrace(); } @@ -69,15 +73,19 @@ public class AlignFrame extends Frame implements ActionListener, seqLimits.setState(viewport.showJVSuffix); - if(applet!=null) + if (applet != null) { String param = applet.getParameter("sortBy"); if (param != null) { if (param.equalsIgnoreCase("Id")) + { sortIDMenuItem_actionPerformed(); + } else if (param.equalsIgnoreCase("Pairwise Identity")) + { sortPairwiseMenuItem_actionPerformed(); + } } param = applet.getParameter("wrap"); @@ -110,28 +118,28 @@ public class AlignFrame extends Frame implements ActionListener, } - //Some JVMS send keyevents to Top frame or lowest panel, - //Havent worked out why yet. So add to both this frame and seqCanvas for now - this.addKeyListener(this); - alignPanel.seqPanel.seqCanvas.addKeyListener(this); - alignPanel.idPanel.idCanvas.addKeyListener(this); - alignPanel.scalePanel.addKeyListener(this); - alignPanel.annotationPanel.addKeyListener(this); + //Some JVMS send keyevents to Top frame or lowest panel, + //Havent worked out why yet. So add to both this frame and seqCanvas for now + this.addKeyListener(this); + alignPanel.seqPanel.seqCanvas.addKeyListener(this); + alignPanel.idPanel.idCanvas.addKeyListener(this); + alignPanel.scalePanel.addKeyListener(this); + alignPanel.annotationPanel.addKeyListener(this); - - if(embedded) - { - setEmbedded(); - } - else - { - add(alignPanel, BorderLayout.CENTER); - jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH, - DEFAULT_HEIGHT); - } - alignPanel.validate(); - alignPanel.repaint(); + if (embedded) + { + setEmbedded(); + } + else + { + add(alignPanel, BorderLayout.CENTER); + jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH, + DEFAULT_HEIGHT); + } + alignPanel.validate(); + alignPanel.repaint(); } + public AlignViewport getAlignViewport() { return viewport; @@ -142,7 +150,6 @@ public class AlignFrame extends Frame implements ActionListener, return alignPanel.seqPanel.seqCanvas; } - /** * DOCUMENT ME! * @@ -153,23 +160,27 @@ public class AlignFrame extends Frame implements ActionListener, { Hashtable featureLinks = new Hashtable(); boolean featuresFile = false; - try{ - featuresFile = new jalview.io.FeaturesFile(file, type).parse(viewport.alignment, - alignPanel.seqPanel.seqCanvas. - getFeatureRenderer().featureColours, - featureLinks, - true); + try + { + featuresFile = new jalview.io.FeaturesFile(file, + type).parse(viewport.alignment, + alignPanel.seqPanel.seqCanvas. + getFeatureRenderer().featureColours, + featureLinks, + true); } - catch(Exception ex) + catch (Exception ex) { ex.printStackTrace(); } - if(featuresFile) + if (featuresFile) { - if(featureLinks.size()>0) + if (featureLinks.size() > 0) + { alignPanel.seqPanel.seqCanvas .getFeatureRenderer().featureLinks = featureLinks; + } viewport.showSequenceFeatures = true; sequenceFeatures.setState(true); alignPanel.repaint(); @@ -177,7 +188,6 @@ public class AlignFrame extends Frame implements ActionListener, } - public void keyPressed(KeyEvent evt) { if (viewport.cursorMode @@ -221,38 +231,42 @@ public class AlignFrame extends Frame implements ActionListener, } break; case KeyEvent.VK_DOWN: - if(viewport.cursorMode) + if (viewport.cursorMode) { - alignPanel.seqPanel.moveCursor(0,1); + alignPanel.seqPanel.moveCursor(0, 1); } else + { moveSelectedSequences(false); + } break; case KeyEvent.VK_UP: if (viewport.cursorMode) { - alignPanel.seqPanel.moveCursor(0,-1); + alignPanel.seqPanel.moveCursor(0, -1); } else + { moveSelectedSequences(true); + } break; case KeyEvent.VK_LEFT: - if(viewport.cursorMode) + if (viewport.cursorMode) { - alignPanel.seqPanel.moveCursor(-1,0); + alignPanel.seqPanel.moveCursor( -1, 0); } break; case KeyEvent.VK_RIGHT: if (viewport.cursorMode) { - alignPanel.seqPanel.moveCursor(1,0); + alignPanel.seqPanel.moveCursor(1, 0); } break; case KeyEvent.VK_SPACE: - if(viewport.cursorMode) + if (viewport.cursorMode) { alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown() || evt.isShiftDown() @@ -263,13 +277,13 @@ public class AlignFrame extends Frame implements ActionListener, case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: - if(viewport.cursorMode) + if (viewport.cursorMode) { alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown() || evt.isShiftDown() || evt.isAltDown()); } - else + else { cut_actionPerformed(); alignPanel.seqPanel.seqCanvas.repaint(); @@ -277,13 +291,13 @@ public class AlignFrame extends Frame implements ActionListener, break; case KeyEvent.VK_S: - if(viewport.cursorMode) + if (viewport.cursorMode) { alignPanel.seqPanel.setCursorRow(); } break; case KeyEvent.VK_P: - if(viewport.cursorMode) + if (viewport.cursorMode) { alignPanel.seqPanel.setCursorPosition(); } @@ -291,35 +305,35 @@ public class AlignFrame extends Frame implements ActionListener, case KeyEvent.VK_ENTER: case KeyEvent.VK_COMMA: - if(viewport.cursorMode) + if (viewport.cursorMode) { alignPanel.seqPanel.setCursorRowAndColumn(); } break; case KeyEvent.VK_Q: - if(viewport.cursorMode) + if (viewport.cursorMode) { alignPanel.seqPanel.setSelectionAreaAtCursor(true); } break; case KeyEvent.VK_M: - if(viewport.cursorMode) + if (viewport.cursorMode) { alignPanel.seqPanel.setSelectionAreaAtCursor(false); } break; - case KeyEvent.VK_F2: - viewport.cursorMode = ! viewport.cursorMode; - statusBar.setText("Keyboard editing mode is "+ - (viewport.cursorMode ? "on" : "off")); - if(viewport.cursorMode) - { - alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes; - alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq; - } - break; + case KeyEvent.VK_F2: + viewport.cursorMode = !viewport.cursorMode; + statusBar.setText("Keyboard editing mode is " + + (viewport.cursorMode ? "on" : "off")); + if (viewport.cursorMode) + { + alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes; + alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq; + } + break; case KeyEvent.VK_F: if (evt.isControlDown()) @@ -335,47 +349,61 @@ public class AlignFrame extends Frame implements ActionListener, boolean hide = false; SequenceGroup sg = viewport.getSelectionGroup(); - if(toggleSeqs) + if (toggleSeqs) { if (sg != null && sg.getSize() != viewport.alignment.getHeight()) { hide = true; viewport.hideAllSelectedSeqs(); } - else if (!(toggleCols && viewport.colSel.getSelected().size() > 0)) + else if (! (toggleCols && viewport.colSel.getSelected().size() > 0)) + { viewport.showAllHiddenSeqs(); + } } - if(toggleCols) + if (toggleCols) { if (viewport.colSel.getSelected().size() > 0) { viewport.hideSelectedColumns(); - if(!toggleSeqs) - viewport.selectionGroup = sg; + if (!toggleSeqs) + { + viewport.selectionGroup = sg; + } } else if (!hide) + { viewport.showAllHiddenColumns(); + } } break; } case KeyEvent.VK_PAGE_UP: if (viewport.wrapAlignment) + { alignPanel.scrollUp(true); + } else + { alignPanel.setScrollValues(viewport.startRes, viewport.startSeq - viewport.endSeq + viewport.startSeq); + } break; case KeyEvent.VK_PAGE_DOWN: if (viewport.wrapAlignment) + { alignPanel.scrollUp(false); + } else + { alignPanel.setScrollValues(viewport.startRes, viewport.startSeq + viewport.endSeq - viewport.startSeq); + } break; case KeyEvent.VK_Z: @@ -410,18 +438,26 @@ public class AlignFrame extends Frame implements ActionListener, if (evt.isControlDown()) { if (evt.isShiftDown()) + { this.removeAllGapsMenuItem_actionPerformed(); + } else + { removeGappedColumnMenuItem_actionPerformed(); + } } break; case KeyEvent.VK_I: if (evt.isControlDown()) { if (evt.isAltDown()) + { viewport.invertColumnSelection(); + } else + { this.invertSequenceMenuItem_actionPerformed(); + } } break; @@ -430,213 +466,364 @@ public class AlignFrame extends Frame implements ActionListener, { this.deleteGroups_actionPerformed(); } - break; - - case KeyEvent.VK_T: - if (evt.isControlDown()) - { - newView(); - } - break; + break; + case KeyEvent.VK_T: + if (evt.isControlDown()) + { + newView(); + } + break; - } - alignPanel.repaint(); + } + alignPanel.repaint(); } + public void keyReleased(KeyEvent evt) {} + public void keyTyped(KeyEvent evt) {} -public void itemStateChanged(ItemEvent evt) - { - if(evt.getSource()==colourTextMenuItem) - colourTextMenuItem_actionPerformed(); - else if(evt.getSource()==wrapMenuItem) - wrapMenuItem_actionPerformed(); - else if(evt.getSource()==scaleAbove) - viewport.setScaleAboveWrapped(scaleAbove.getState()); - else if(evt.getSource()==scaleLeft) - viewport.setScaleLeftWrapped(scaleLeft.getState()); - else if(evt.getSource()==scaleRight) - viewport.setScaleRightWrapped(scaleRight.getState()); - else if(evt.getSource()==seqLimits) + public void itemStateChanged(ItemEvent evt) + { + if (evt.getSource() == colourTextMenuItem) + { + colourTextMenuItem_actionPerformed(); + } + else if (evt.getSource() == wrapMenuItem) + { + wrapMenuItem_actionPerformed(); + } + else if (evt.getSource() == scaleAbove) + { + viewport.setScaleAboveWrapped(scaleAbove.getState()); + } + else if (evt.getSource() == scaleLeft) + { + viewport.setScaleLeftWrapped(scaleLeft.getState()); + } + else if (evt.getSource() == scaleRight) + { + viewport.setScaleRightWrapped(scaleRight.getState()); + } + else if (evt.getSource() == seqLimits) + { seqLimits_itemStateChanged(); - else if(evt.getSource()==viewBoxesMenuItem) - viewport.setShowBoxes(viewBoxesMenuItem.getState()); - else if(evt.getSource()==viewTextMenuItem) - viewport.setShowText(viewTextMenuItem.getState()); - else if(evt.getSource()==renderGapsMenuItem) - viewport.setRenderGaps(renderGapsMenuItem.getState()); - else if(evt.getSource()==annotationPanelMenuItem) + } + else if (evt.getSource() == viewBoxesMenuItem) + { + viewport.setShowBoxes(viewBoxesMenuItem.getState()); + } + else if (evt.getSource() == viewTextMenuItem) + { + viewport.setShowText(viewTextMenuItem.getState()); + } + else if (evt.getSource() == renderGapsMenuItem) + { + viewport.setRenderGaps(renderGapsMenuItem.getState()); + } + else if (evt.getSource() == annotationPanelMenuItem) { viewport.setShowAnnotation(annotationPanelMenuItem.getState()); alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState()); } - else if(evt.getSource()==sequenceFeatures) - { - viewport.showSequenceFeatures(sequenceFeatures.getState()); - alignPanel.seqPanel.seqCanvas.repaint(); - } - else if(evt.getSource()==conservationMenuItem) - conservationMenuItem_actionPerformed(); - else if(evt.getSource()==abovePIDThreshold) - abovePIDThreshold_actionPerformed(); - else if(evt.getSource()==applyToAllGroups) - viewport.setColourAppliesToAllGroups(applyToAllGroups.getState()); - else if(evt.getSource()==autoCalculate) - viewport.autocalculateConsensus = autoCalculate.getState(); + else if (evt.getSource() == sequenceFeatures) + { + viewport.showSequenceFeatures(sequenceFeatures.getState()); + alignPanel.seqPanel.seqCanvas.repaint(); + } + else if (evt.getSource() == conservationMenuItem) + { + conservationMenuItem_actionPerformed(); + } + else if (evt.getSource() == abovePIDThreshold) + { + abovePIDThreshold_actionPerformed(); + } + else if (evt.getSource() == applyToAllGroups) + { + viewport.setColourAppliesToAllGroups(applyToAllGroups.getState()); + } + else if (evt.getSource() == autoCalculate) + { + viewport.autocalculateConsensus = autoCalculate.getState(); + } - alignPanel.repaint(); + alignPanel.repaint(); } - public void actionPerformed(ActionEvent evt) - { + + public void actionPerformed(ActionEvent evt) + { Object source = evt.getSource(); - if(source==inputText) + if (source == inputText) + { inputText_actionPerformed(); - else if(source==loadTree) + } + else if (source == loadTree) + { loadTree_actionPerformed(); - else if(source==loadApplication) + } + else if (source == loadApplication) + { launchFullApplication(); + } else if (source == loadAnnotations) + { loadAnnotations(); + } else if (source == outputAnnotations) + { outputAnnotations(true); - else if(source == outputFeatures) + } + else if (source == outputFeatures) + { outputFeatures(true, "Jalview"); - else if(source==closeMenuItem) + } + else if (source == closeMenuItem) + { closeMenuItem_actionPerformed(); - else if(source==copy) + } + else if (source == copy) + { copy_actionPerformed(); - else if(source==undoMenuItem) + } + else if (source == undoMenuItem) + { undoMenuItem_actionPerformed(); - else if(source==redoMenuItem) + } + else if (source == redoMenuItem) + { redoMenuItem_actionPerformed(); - else if(source==inputText) - inputText_actionPerformed(); - else if(source==closeMenuItem) - closeMenuItem_actionPerformed(); - else if(source==undoMenuItem) - undoMenuItem_actionPerformed(); - else if(source==redoMenuItem) - redoMenuItem_actionPerformed(); - else if(source==copy) - copy_actionPerformed(); - else if(source==pasteNew) - pasteNew_actionPerformed(); - else if(source==pasteThis) - pasteThis_actionPerformed(); - else if(source==cut) - cut_actionPerformed(); - else if(source==delete) - delete_actionPerformed(); - else if(source==deleteGroups) - deleteGroups_actionPerformed(); - else if(source==selectAllSequenceMenuItem) - selectAllSequenceMenuItem_actionPerformed(); - else if(source==deselectAllSequenceMenuItem) - deselectAllSequenceMenuItem_actionPerformed(); - else if(source==invertSequenceMenuItem) - invertSequenceMenuItem_actionPerformed(); - else if(source==invertColSel) - { viewport.invertColumnSelection(); alignPanel.repaint(); } - else if(source==remove2LeftMenuItem) - trimAlignment(true); - else if(source==remove2RightMenuItem) - trimAlignment(false); - else if(source==removeGappedColumnMenuItem) - removeGappedColumnMenuItem_actionPerformed(); - else if(source==removeAllGapsMenuItem) - removeAllGapsMenuItem_actionPerformed(); - else if(source==findMenuItem) - findMenuItem_actionPerformed(); - else if(source==font) - new FontChooser(alignPanel); + } + else if (source == inputText) + { + inputText_actionPerformed(); + } + else if (source == closeMenuItem) + { + closeMenuItem_actionPerformed(); + } + else if (source == undoMenuItem) + { + undoMenuItem_actionPerformed(); + } + else if (source == redoMenuItem) + { + redoMenuItem_actionPerformed(); + } + else if (source == copy) + { + copy_actionPerformed(); + } + else if (source == pasteNew) + { + pasteNew_actionPerformed(); + } + else if (source == pasteThis) + { + pasteThis_actionPerformed(); + } + else if (source == cut) + { + cut_actionPerformed(); + } + else if (source == delete) + { + delete_actionPerformed(); + } + else if (source == deleteGroups) + { + deleteGroups_actionPerformed(); + } + else if (source == selectAllSequenceMenuItem) + { + selectAllSequenceMenuItem_actionPerformed(); + } + else if (source == deselectAllSequenceMenuItem) + { + deselectAllSequenceMenuItem_actionPerformed(); + } + else if (source == invertSequenceMenuItem) + { + invertSequenceMenuItem_actionPerformed(); + } + else if (source == invertColSel) + { + viewport.invertColumnSelection(); + alignPanel.repaint(); + } + else if (source == remove2LeftMenuItem) + { + trimAlignment(true); + } + else if (source == remove2RightMenuItem) + { + trimAlignment(false); + } + else if (source == removeGappedColumnMenuItem) + { + removeGappedColumnMenuItem_actionPerformed(); + } + else if (source == removeAllGapsMenuItem) + { + removeAllGapsMenuItem_actionPerformed(); + } + else if (source == findMenuItem) + { + findMenuItem_actionPerformed(); + } + else if (source == font) + { + new FontChooser(alignPanel); + } else if (source == newView) + { newView(); - else if(source==showColumns) + } + else if (source == showColumns) { - viewport.showAllHiddenColumns(); alignPanel.repaint(); + viewport.showAllHiddenColumns(); + alignPanel.repaint(); } - else if(source==showSeqs) + else if (source == showSeqs) { viewport.showAllHiddenSeqs(); } - else if(source == hideColumns) + else if (source == hideColumns) { - viewport.hideSelectedColumns(); alignPanel.repaint(); + viewport.hideSelectedColumns(); + alignPanel.repaint(); } - else if(source == hideSequences && viewport.getSelectionGroup()!=null) + else if (source == hideSequences && viewport.getSelectionGroup() != null) { viewport.hideAllSelectedSeqs(); } - else if(source==featureSettings) - new FeatureSettings(alignPanel); - else if(source==overviewMenuItem) - overviewMenuItem_actionPerformed(); - else if(source==noColourmenuItem) - changeColour(null); - else if(source==clustalColour) + else if (source == featureSettings) + { + new FeatureSettings(alignPanel); + } + else if (source == overviewMenuItem) + { + overviewMenuItem_actionPerformed(); + } + else if (source == noColourmenuItem) + { + changeColour(null); + } + else if (source == clustalColour) { abovePIDThreshold.setState(false); changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(), viewport.alignment.getWidth())); + } + else if (source == zappoColour) + { + changeColour(new ZappoColourScheme()); + } + else if (source == taylorColour) + { + changeColour(new TaylorColourScheme()); + } + else if (source == hydrophobicityColour) + { + changeColour(new HydrophobicColourScheme()); + } + else if (source == helixColour) + { + changeColour(new HelixColourScheme()); + } + else if (source == strandColour) + { + changeColour(new StrandColourScheme()); + } + else if (source == turnColour) + { + changeColour(new TurnColourScheme()); + } + else if (source == buriedColour) + { + changeColour(new BuriedColourScheme()); + } + else if (source == nucleotideColour) + { + changeColour(new NucleotideColourScheme()); + } + else if (source == modifyPID) + { + modifyPID_actionPerformed(); + } + else if (source == modifyConservation) + { + modifyConservation_actionPerformed(); + } + else if (source == userDefinedColour) + { + new UserDefinedColours(alignPanel, null); + } + else if (source == PIDColour) + { + changeColour(new PIDColourScheme()); + } + else if (source == BLOSUM62Colour) + { + changeColour(new Blosum62ColourScheme()); + } + else if (source == annotationColour) + { + new AnnotationColourChooser(viewport, alignPanel); + } + else if (source == sortPairwiseMenuItem) + { + sortPairwiseMenuItem_actionPerformed(); + } + else if (source == sortIDMenuItem) + { + sortIDMenuItem_actionPerformed(); + } + else if (source == sortGroupMenuItem) + { + sortGroupMenuItem_actionPerformed(); + } + else if (source == removeRedundancyMenuItem) + { + removeRedundancyMenuItem_actionPerformed(); + } + else if (source == pairwiseAlignmentMenuItem) + { + pairwiseAlignmentMenuItem_actionPerformed(); + } + else if (source == PCAMenuItem) + { + PCAMenuItem_actionPerformed(); + } + else if (source == averageDistanceTreeMenuItem) + { + averageDistanceTreeMenuItem_actionPerformed(); + } + else if (source == neighbourTreeMenuItem) + { + neighbourTreeMenuItem_actionPerformed(); + } + else if (source == njTreeBlosumMenuItem) + { + njTreeBlosumMenuItem_actionPerformed(); + } + else if (source == avDistanceTreeBlosumMenuItem) + { + avTreeBlosumMenuItem_actionPerformed(); + } + else if (source == documentation) + { + documentation_actionPerformed(); + } + else if (source == about) + { + about_actionPerformed(); + } + } - else if(source==zappoColour) - changeColour(new ZappoColourScheme()); - else if(source==taylorColour) - changeColour(new TaylorColourScheme()); - else if(source==hydrophobicityColour) - changeColour(new HydrophobicColourScheme()); - else if(source==helixColour) - changeColour(new HelixColourScheme()); - else if(source==strandColour) - changeColour(new StrandColourScheme()); - else if(source==turnColour) - changeColour(new TurnColourScheme()); - else if(source==buriedColour) - changeColour(new BuriedColourScheme()); - else if(source==nucleotideColour) - changeColour(new NucleotideColourScheme()); - else if(source==modifyPID) - modifyPID_actionPerformed(); - else if(source==modifyConservation) - modifyConservation_actionPerformed(); - else if(source==userDefinedColour) - new UserDefinedColours(alignPanel, null); - else if(source==PIDColour) - changeColour(new PIDColourScheme()); - else if(source==BLOSUM62Colour) - changeColour(new Blosum62ColourScheme()); - else if(source==annotationColour) - new AnnotationColourChooser(viewport, alignPanel); - else if(source==sortPairwiseMenuItem) - sortPairwiseMenuItem_actionPerformed(); - else if(source==sortIDMenuItem) - sortIDMenuItem_actionPerformed(); - else if(source==sortGroupMenuItem) - sortGroupMenuItem_actionPerformed(); - else if(source==removeRedundancyMenuItem) - removeRedundancyMenuItem_actionPerformed(); - else if(source==pairwiseAlignmentMenuItem) - pairwiseAlignmentMenuItem_actionPerformed(); - else if(source==PCAMenuItem) - PCAMenuItem_actionPerformed(); - else if(source==averageDistanceTreeMenuItem) - averageDistanceTreeMenuItem_actionPerformed(); - else if(source==neighbourTreeMenuItem) - neighbourTreeMenuItem_actionPerformed(); - else if(source==njTreeBlosumMenuItem) - njTreeBlosumMenuItem_actionPerformed(); - else if(source==avDistanceTreeBlosumMenuItem) - avTreeBlosumMenuItem_actionPerformed(); - else if(source==documentation) - documentation_actionPerformed(); - else if(source==about) - about_actionPerformed(); - - } public void inputText_actionPerformed() { @@ -655,8 +842,8 @@ public void itemStateChanged(ItemEvent evt) "Alignment output - " + e.getActionCommand(), 600, 500); cap.setText(new AppletFormatAdapter().formatSequences(e.getActionCommand(), - viewport.getAlignment(), - viewport.showJVSuffix)); + viewport.getAlignment(), + viewport.showJVSuffix)); } public void loadAnnotations() @@ -666,7 +853,7 @@ public void itemStateChanged(ItemEvent evt) cap.setAnnotationImport(); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300); + jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300); } @@ -676,7 +863,7 @@ public void itemStateChanged(ItemEvent evt) viewport.showAnnotation ? viewport.alignment.getAlignmentAnnotation() : null, viewport.alignment.getGroups()); - if(displayTextbox) + if (displayTextbox) { CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); Frame frame = new Frame(); @@ -694,16 +881,19 @@ public void itemStateChanged(ItemEvent evt) { String features; if (format.equalsIgnoreCase("Jalview")) + { features = new FeaturesFile().printJalviewFormat( - viewport.alignment.getSequencesArray(), - viewport.featuresDisplayed); + viewport.alignment.getSequencesArray(), + viewport.featuresDisplayed); + } else + { features = new FeaturesFile().printGFFFormat( - viewport.alignment.getSequencesArray(), - viewport.featuresDisplayed); - + viewport.alignment.getSequencesArray(), + viewport.featuresDisplayed); + } - if(displayTextbox) + if (displayTextbox) { CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); Frame frame = new Frame(); @@ -722,67 +912,72 @@ public void itemStateChanged(ItemEvent evt) { StringBuffer url = new StringBuffer(jalviewServletURL); - url.append("?open="+ - appendProtocol( viewport.applet.getParameter("file") ) ); + url.append("?open=" + + appendProtocol(viewport.applet.getParameter("file"))); - if(viewport.applet.getParameter("features")!=null) + if (viewport.applet.getParameter("features") != null) { - url.append( "&features=" ); - url.append( appendProtocol( viewport.applet.getParameter("features") ) ); + url.append("&features="); + url.append(appendProtocol(viewport.applet.getParameter("features"))); } - if(viewport.applet.getParameter("annotations")!=null) + if (viewport.applet.getParameter("annotations") != null) { - url.append( "&annotations=" ); - url.append( appendProtocol( viewport.applet.getParameter("annotations") ) ); + url.append("&annotations="); + url.append(appendProtocol(viewport.applet.getParameter("annotations"))); } - if(viewport.applet.getParameter("jnetfile")!=null) + if (viewport.applet.getParameter("jnetfile") != null) { - url.append( "&annotations=" ); - url.append( appendProtocol( viewport.applet.getParameter("jnetfile") ) ); + url.append("&annotations="); + url.append(appendProtocol(viewport.applet.getParameter("jnetfile"))); } - if(viewport.applet.getParameter("defaultColour")!=null) + if (viewport.applet.getParameter("defaultColour") != null) { url.append("&colour=" + removeWhiteSpace(viewport.applet.getParameter("defaultColour")) ); } - if(viewport.applet.getParameter("userDefinedColour")!=null) + if (viewport.applet.getParameter("userDefinedColour") != null) { - url.append( "&colour=" + - removeWhiteSpace( viewport.applet.getParameter("userDefinedColour") ) - ); + url.append("&colour=" + + removeWhiteSpace(viewport.applet.getParameter( + "userDefinedColour")) + ); } showURL(url.toString(), "FULL_APP"); } - String removeWhiteSpace(String colour) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < colour.length(); i++) { if (Character.isWhitespace(colour.charAt(i))) + { sb.append("%20"); + } else + { sb.append(colour.charAt(i)); + } } return sb.toString(); } - String appendProtocol(String url) { - try{ - new URL(url); - }catch(java.net.MalformedURLException ex) + try + { + new URL(url); + } + catch (java.net.MalformedURLException ex) { - url = viewport.applet.getCodeBase()+url; + url = viewport.applet.getCodeBase() + url; } return url; } @@ -793,13 +988,14 @@ public void itemStateChanged(ItemEvent evt) PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas); PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas); - if(PaintRefresher.components.size()==0 && viewport.applet==null) + if (PaintRefresher.components.size() == 0 && viewport.applet == null) + { System.exit(0); + } this.dispose(); } - /** * DOCUMENT ME! */ @@ -834,7 +1030,7 @@ public void itemStateChanged(ItemEvent evt) public void addHistoryItem(CommandI command) { - if(command.getSize()>0) + if (command.getSize() > 0) { viewport.historyList.push(command); viewport.redoList.removeAllElements(); @@ -850,10 +1046,12 @@ public void itemStateChanged(ItemEvent evt) */ protected void undoMenuItem_actionPerformed() { - if(viewport.historyList.size()<1) + if (viewport.historyList.size() < 1) + { return; + } - CommandI command = (CommandI)viewport.historyList.pop(); + CommandI command = (CommandI) viewport.historyList.pop(); viewport.redoList.push(command); command.undoCommand(); @@ -861,7 +1059,8 @@ public void itemStateChanged(ItemEvent evt) originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null; updateEditMenuBar(); - originalSource.firePropertyChange("alignment", null,originalSource.alignment.getSequences()); + originalSource.firePropertyChange("alignment", null, + originalSource.alignment.getSequences()); } /** @@ -871,27 +1070,30 @@ public void itemStateChanged(ItemEvent evt) */ protected void redoMenuItem_actionPerformed() { - if(viewport.redoList.size()<1) + if (viewport.redoList.size() < 1) + { return; + } CommandI command = (CommandI) viewport.redoList.pop(); viewport.historyList.push(command); command.doCommand(); AlignViewport originalSource = getOriginatingSource(command); - originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null; + originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null; updateEditMenuBar(); - originalSource.firePropertyChange("alignment", null, originalSource.alignment.getSequences()); + originalSource.firePropertyChange("alignment", null, + originalSource.alignment.getSequences()); } AlignViewport getOriginatingSource(CommandI command) { AlignViewport originalSource = null; //For sequence removal and addition, we need to fire - //the property change event FROM the viewport where the - //original alignment was altered - AlignmentI al = null; + //the property change event FROM the viewport where the + //original alignment was altered + AlignmentI al = null; if (command instanceof EditCommand) { EditCommand editCommand = (EditCommand) command; @@ -916,12 +1118,13 @@ public void itemStateChanged(ItemEvent evt) //The original view is closed, we must validate //the current view against the closed view first if (al != null) + { PaintRefresher.validateSequences(al, viewport.alignment); + } originalSource = viewport; } - return originalSource; } @@ -1010,60 +1213,61 @@ public void itemStateChanged(ItemEvent evt) viewport.getColumnSelection().getHiddenColumns().elementAt(i); copiedHiddenColumns.addElement(new int[] - {region[0] - hiddenOffset, - region[1] - hiddenOffset}); + {region[0] - hiddenOffset, + region[1] - hiddenOffset}); } } else + { copiedHiddenColumns = null; - + } for (int i = 0; i < sg.getSize(); i++) { - SequenceI seq = null; + SequenceI seq = null; - while (seq == null) + while (seq == null) + { + if (orderedSeqs.containsKey(index + "")) { - if (orderedSeqs.containsKey(index + "")) - { - seq = (SequenceI) orderedSeqs.get(index + ""); - index++; + seq = (SequenceI) orderedSeqs.get(index + ""); + index++; - break; - } - else - { - index++; - } + break; + } + else + { + index++; } + } - //FIND START RES - //Returns residue following index if gap - startRes = seq.findPosition(sg.getStartRes()); + //FIND START RES + //Returns residue following index if gap + startRes = seq.findPosition(sg.getStartRes()); - //FIND END RES - //Need to find the residue preceeding index if gap - endRes = 0; + //FIND END RES + //Need to find the residue preceeding index if gap + endRes = 0; - for (int j = 0; j < sg.getEndRes()+1 && j < seq.getLength(); j++) + for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++) + { + ch = seq.getCharAt(j); + if (!jalview.util.Comparison.isGap( (ch))) { - ch = seq.getCharAt(j); - if (!jalview.util.Comparison.isGap( (ch))) - { - endRes++; - } + endRes++; } + } - if(endRes>0) - { - endRes += seq.getStart() -1; - } + if (endRes > 0) + { + endRes += seq.getStart() - 1; + } - copiedSequences.append(seq.getName() + "\t" + - startRes + "\t" + - endRes + "\t" + - seq.getSequenceAsString(sg.getStartRes(), - sg.getEndRes() + 1) + "\n"); + copiedSequences.append(seq.getName() + "\t" + + startRes + "\t" + + endRes + "\t" + + seq.getSequenceAsString(sg.getStartRes(), + sg.getEndRes() + 1) + "\n"); } } @@ -1127,7 +1331,6 @@ public void itemStateChanged(ItemEvent evt) } } - jalview.bin.JalviewLite.addFrame(af, newtitle, DEFAULT_WIDTH, DEFAULT_HEIGHT); } @@ -1189,47 +1392,45 @@ public void itemStateChanged(ItemEvent evt) seqs.addElement(seq); } + // If the cut affects all sequences, remove highlighted columns + if (sg.getSize() == viewport.alignment.getHeight()) + { + viewport.getColumnSelection().removeElements(sg.getStartRes(), + sg.getEndRes() + 1); + } - // If the cut affects all sequences, remove highlighted columns - if (sg.getSize() == viewport.alignment.getHeight()) - { - viewport.getColumnSelection().removeElements(sg.getStartRes(), - sg.getEndRes() + 1); - } - - - SequenceI [] cut = new SequenceI[seqs.size()]; - for(int i=0; i 0) { - if(trimLeft) + if (trimLeft) + { column = colSel.getMin(); + } else + { column = colSel.getMax(); + } - SequenceI [] seqs; - if(viewport.getSelectionGroup()!=null) - seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.hiddenRepSequences); + SequenceI[] seqs; + if (viewport.getSelectionGroup() != null) + { + seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport. + hiddenRepSequences); + } else + { seqs = viewport.alignment.getSequencesArray(); - + } TrimRegionCommand trimRegion; - if(trimLeft) + if (trimLeft) { trimRegion = new TrimRegionCommand("Remove Left", - TrimRegionCommand.TRIM_LEFT, - seqs, - column, - viewport.alignment, - viewport.colSel, - viewport.selectionGroup); + TrimRegionCommand.TRIM_LEFT, + seqs, + column, + viewport.alignment, + viewport.colSel, + viewport.selectionGroup); viewport.setStartRes(0); } - else - { - trimRegion = new TrimRegionCommand("Remove Right", - TrimRegionCommand.TRIM_RIGHT, - seqs, - column, - viewport.alignment, - viewport.colSel, - viewport.selectionGroup); - } - - statusBar.setText("Removed "+trimRegion.getSize()+" columns."); + else + { + trimRegion = new TrimRegionCommand("Remove Right", + TrimRegionCommand.TRIM_RIGHT, + seqs, + column, + viewport.alignment, + viewport.colSel, + viewport.selectionGroup); + } + statusBar.setText("Removed " + trimRegion.getSize() + " columns."); addHistoryItem(trimRegion); @@ -1340,21 +1548,22 @@ public void itemStateChanged(ItemEvent evt) } } - public void removeGappedColumnMenuItem_actionPerformed() { - int start = 0, end = viewport.alignment.getWidth()-1; + int start = 0, end = viewport.alignment.getWidth() - 1; SequenceI[] seqs; if (viewport.getSelectionGroup() != null) { - seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.hiddenRepSequences); + seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport. + hiddenRepSequences); start = viewport.getSelectionGroup().getStartRes(); end = viewport.getSelectionGroup().getEndRes(); } else + { seqs = viewport.alignment.getSequencesArray(); - + } RemoveGapColCommand removeGapCols = new RemoveGapColCommand("Remove Gapped Columns", @@ -1364,35 +1573,39 @@ public void itemStateChanged(ItemEvent evt) addHistoryItem(removeGapCols); - statusBar.setText("Removed "+removeGapCols.getSize()+" empty columns."); + statusBar.setText("Removed " + removeGapCols.getSize() + " empty columns."); //This is to maintain viewport position on first residue //of first sequence SequenceI seq = viewport.alignment.getSequenceAt(0); int startRes = seq.findPosition(viewport.startRes); - // ShiftList shifts; - // viewport.getAlignment().removeGaps(shifts=new ShiftList()); - // edit.alColumnChanges=shifts.getInverse(); - // if (viewport.hasHiddenColumns) - // viewport.getColumnSelection().compensateForEdits(shifts); - viewport.setStartRes(seq.findIndex(startRes)-1); - viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); + // ShiftList shifts; + // viewport.getAlignment().removeGaps(shifts=new ShiftList()); + // edit.alColumnChanges=shifts.getInverse(); + // if (viewport.hasHiddenColumns) + // viewport.getColumnSelection().compensateForEdits(shifts); + viewport.setStartRes(seq.findIndex(startRes) - 1); + viewport.firePropertyChange("alignment", null, + viewport.getAlignment().getSequences()); } public void removeAllGapsMenuItem_actionPerformed() { - int start = 0, end = viewport.alignment.getWidth()-1; + int start = 0, end = viewport.alignment.getWidth() - 1; SequenceI[] seqs; if (viewport.getSelectionGroup() != null) { - seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.hiddenRepSequences); + seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport. + hiddenRepSequences); start = viewport.getSelectionGroup().getStartRes(); end = viewport.getSelectionGroup().getEndRes(); } else + { seqs = viewport.alignment.getSequencesArray(); + } //This is to maintain viewport position on first residue //of first sequence @@ -1400,13 +1613,14 @@ public void itemStateChanged(ItemEvent evt) int startRes = seq.findPosition(viewport.startRes); addHistoryItem(new RemoveGapsCommand("Remove Gaps", - seqs, - start, end, - viewport.alignment)); + seqs, + start, end, + viewport.alignment)); - viewport.setStartRes(seq.findIndex(startRes)-1); + viewport.setStartRes(seq.findIndex(startRes) - 1); - viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); + viewport.firePropertyChange("alignment", null, + viewport.getAlignment().getSequences()); } @@ -1419,18 +1633,22 @@ public void itemStateChanged(ItemEvent evt) { AlignmentI newal; if (viewport.hasHiddenRows) + { newal = new Alignment(viewport.getAlignment(). getHiddenSequences() .getFullAlignment(). getSequencesArray()); + } else + { newal = new Alignment(viewport.alignment.getSequencesArray()); + } - if(viewport.alignment.getAlignmentAnnotation()!=null) + if (viewport.alignment.getAlignmentAnnotation() != null) { - for(int i=0; i -1) + { title = title.substring(0, title.indexOf("(View")); + } - title+= "(View "+viewSize+")"; + title += "(View " + viewSize + ")"; newaf.setTitle(title.toString()); - newaf.viewport.historyList = viewport.historyList; newaf.viewport.redoList = viewport.redoList; - } - + } public void seqLimits_itemStateChanged() { @@ -1482,7 +1703,6 @@ public void itemStateChanged(ItemEvent evt) alignPanel.repaint(); } - protected void colourTextMenuItem_actionPerformed() { viewport.setColourText(colourTextMenuItem.getState()); @@ -1499,7 +1719,6 @@ public void itemStateChanged(ItemEvent evt) alignPanel.repaint(); } - public void overviewMenuItem_actionPerformed() { if (alignPanel.overviewPanel != null) @@ -1528,12 +1747,11 @@ public void itemStateChanged(ItemEvent evt) } - void changeColour(ColourSchemeI cs) { int threshold = 0; - if(cs!=null) + if (cs != null) { if (viewport.getAbovePIDThreshold()) { @@ -1583,7 +1801,7 @@ public void itemStateChanged(ItemEvent evt) { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - if(cs==null) + if (cs == null) { sg.cs = null; continue; @@ -1616,13 +1834,16 @@ public void itemStateChanged(ItemEvent evt) sg.getSequences(viewport.hiddenRepSequences), 0, sg.getWidth())); } else + { sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus()); + } if (viewport.getConservationSelected()) { Conservation c = new Conservation("Group", ResidueProperties.propHash, 3, - sg.getSequences(viewport.hiddenRepSequences), 0, + sg.getSequences(viewport. + hiddenRepSequences), 0, viewport.alignment.getWidth() - 1); c.calculate(); c.verdict(false, viewport.ConsPercGaps); @@ -1637,7 +1858,6 @@ public void itemStateChanged(ItemEvent evt) } } - if (alignPanel.getOverviewPanel() != null) { alignPanel.getOverviewPanel().updateOverviewImage(); @@ -1646,11 +1866,9 @@ public void itemStateChanged(ItemEvent evt) alignPanel.repaint(); } - - protected void modifyPID_actionPerformed() { - if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null) + if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme != null) { SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(), "Background"); @@ -1660,7 +1878,7 @@ public void itemStateChanged(ItemEvent evt) protected void modifyConservation_actionPerformed() { - if (viewport.getConservationSelected() && viewport.globalColourScheme!=null) + if (viewport.getConservationSelected() && viewport.globalColourScheme != null) { SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme, "Background"); @@ -1692,29 +1910,28 @@ public void itemStateChanged(ItemEvent evt) modifyPID_actionPerformed(); } - - public void sortPairwiseMenuItem_actionPerformed() { - SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray(); + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); AlignmentSorter.sortByPID(viewport.getAlignment(), viewport.getAlignment().getSequenceAt(0)); - addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.alignment)); + addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, + viewport.alignment)); alignPanel.repaint(); } public void sortIDMenuItem_actionPerformed() { - // addHistoryItem(new HistoryItem("ID Sort", viewport.alignment, - // HistoryItem.SORT)); + // addHistoryItem(new HistoryItem("ID Sort", viewport.alignment, + // HistoryItem.SORT)); AlignmentSorter.sortByID(viewport.getAlignment()); alignPanel.repaint(); } public void sortGroupMenuItem_actionPerformed() { - // addHistoryItem(new HistoryItem("Group Sort", viewport.alignment, - // HistoryItem.SORT)); + // addHistoryItem(new HistoryItem("Group Sort", viewport.alignment, + // HistoryItem.SORT)); AlignmentSorter.sortByGroup(viewport.getAlignment()); alignPanel.repaint(); @@ -1722,12 +1939,12 @@ public void itemStateChanged(ItemEvent evt) public void removeRedundancyMenuItem_actionPerformed() { - new RedundancyPanel(alignPanel); + new RedundancyPanel(alignPanel); } public void pairwiseAlignmentMenuItem_actionPerformed() { - if (viewport.getSelectionGroup()!=null + if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize() > 1) { Frame frame = new Frame(); @@ -1819,8 +2036,8 @@ public void itemStateChanged(ItemEvent evt) if ( (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize() > 1) - || (viewport.getSelectionGroup() == null - && viewport.alignment.getHeight() > 1)) + || (viewport.getSelectionGroup() == null + && viewport.alignment.getHeight() > 1)) { final TreePanel tp = new TreePanel(viewport, type, @@ -1834,12 +2051,12 @@ public void itemStateChanged(ItemEvent evt) void loadTree_actionPerformed() { - CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); - cap.setText("Paste your Newick tree file here."); - cap.setTreeImport(); - Frame frame = new Frame(); - frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300); + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); + cap.setText("Paste your Newick tree file here."); + cap.setTreeImport(); + Frame frame = new Frame(); + frame.add(cap); + jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300); } public void loadTree(jalview.io.NewickFile tree, String treeFile) @@ -1860,8 +2077,8 @@ public void itemStateChanged(ItemEvent evt) { public void actionPerformed(ActionEvent evt) { - // addHistoryItem(new HistoryItem("Sort", viewport.alignment, - // HistoryItem.SORT)); + // addHistoryItem(new HistoryItem("Sort", viewport.alignment, + // HistoryItem.SORT)); AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree()); alignPanel.repaint(); } @@ -1884,11 +2101,14 @@ public void itemStateChanged(ItemEvent evt) protected void about_actionPerformed() { - class AboutPanel extends Canvas + class AboutPanel + extends Canvas { String version; public AboutPanel(String version) - { this.version = version; } + { + this.version = version; + } public void paint(Graphics g) { @@ -1900,7 +2120,7 @@ public void itemStateChanged(ItemEvent evt) int y = 5, x = 7; g.setColor(Color.black); g.setFont(new Font("Helvetica", Font.BOLD, 14)); - g.drawString("Jalview - Release "+version, 200, y += fh); + g.drawString("Jalview - Release " + version, 200, y += fh); g.setFont(new Font("Helvetica", Font.PLAIN, 12)); g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.", x, y += fh * 2); @@ -1939,7 +2159,6 @@ public void itemStateChanged(ItemEvent evt) } } - Frame frame = new Frame(); frame.add(new AboutPanel(version)); jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200); @@ -1956,9 +2175,9 @@ public void itemStateChanged(ItemEvent evt) { try { - System.out.println("Show url: "+url); + System.out.println("Show url: " + url); viewport.applet.getAppletContext().showDocument(new java.net.URL(url), - target); + target); } catch (Exception ex) { @@ -1967,92 +2186,92 @@ public void itemStateChanged(ItemEvent evt) } } - ////////////////////////////////////////////////////////////////////////////////// //JBuilder Graphics here - protected MenuBar alignFrameMenuBar = new MenuBar(); - protected Menu fileMenu = new Menu("File"); - protected MenuItem loadApplication = new MenuItem("View in Full Application"); - protected MenuItem loadTree = new MenuItem("Load Associated Tree ..."); - protected MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ..."); - protected MenuItem outputFeatures = new MenuItem("Export Features ..."); - protected MenuItem outputAnnotations = new MenuItem("Export Annotations ..."); - - protected MenuItem closeMenuItem = new MenuItem("Close"); - protected Menu editMenu = new Menu("Edit"); - protected Menu viewMenu = new Menu("View"); - protected Menu colourMenu = new Menu("Colour"); - protected Menu calculateMenu = new Menu("Calculate"); - protected MenuItem selectAllSequenceMenuItem = new MenuItem("Select all"); - protected MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All"); - protected MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection"); - protected MenuItem remove2LeftMenuItem = new MenuItem(); - protected MenuItem remove2RightMenuItem = new MenuItem(); - protected MenuItem removeGappedColumnMenuItem = new MenuItem(); - protected MenuItem removeAllGapsMenuItem = new MenuItem(); - protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem(); - protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem(); - protected MenuItem sortPairwiseMenuItem = new MenuItem(); - protected MenuItem sortIDMenuItem = new MenuItem(); - protected MenuItem sortGroupMenuItem = new MenuItem(); - protected MenuItem removeRedundancyMenuItem = new MenuItem(); - protected MenuItem pairwiseAlignmentMenuItem = new MenuItem(); - protected MenuItem PCAMenuItem = new MenuItem(); - protected MenuItem averageDistanceTreeMenuItem = new MenuItem(); - protected MenuItem neighbourTreeMenuItem = new MenuItem(); - BorderLayout borderLayout1 = new BorderLayout(); - public Label statusBar = new Label(); - protected Menu outputTextboxMenu = new Menu(); - protected MenuItem clustalColour = new MenuItem(); - protected MenuItem zappoColour = new MenuItem(); - protected MenuItem taylorColour = new MenuItem(); - protected MenuItem hydrophobicityColour = new MenuItem(); - protected MenuItem helixColour = new MenuItem(); - protected MenuItem strandColour = new MenuItem(); - protected MenuItem turnColour = new MenuItem(); - protected MenuItem buriedColour = new MenuItem(); - protected MenuItem userDefinedColour = new MenuItem(); - protected MenuItem PIDColour = new MenuItem(); - protected MenuItem BLOSUM62Colour = new MenuItem(); - MenuItem njTreeBlosumMenuItem = new MenuItem(); - MenuItem avDistanceTreeBlosumMenuItem = new MenuItem(); - protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem(); - protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem(); - MenuItem overviewMenuItem = new MenuItem(); - protected MenuItem undoMenuItem = new MenuItem(); - protected MenuItem redoMenuItem = new MenuItem(); - protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); - MenuItem noColourmenuItem = new MenuItem(); - protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem(); - protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem(); - MenuItem findMenuItem = new MenuItem(); + protected MenuBar alignFrameMenuBar = new MenuBar(); + protected Menu fileMenu = new Menu("File"); + protected MenuItem loadApplication = new MenuItem("View in Full Application"); + protected MenuItem loadTree = new MenuItem("Load Associated Tree ..."); + protected MenuItem loadAnnotations = new MenuItem( + "Load Features/Annotations ..."); + protected MenuItem outputFeatures = new MenuItem("Export Features ..."); + protected MenuItem outputAnnotations = new MenuItem("Export Annotations ..."); + + protected MenuItem closeMenuItem = new MenuItem("Close"); + protected Menu editMenu = new Menu("Edit"); + protected Menu viewMenu = new Menu("View"); + protected Menu colourMenu = new Menu("Colour"); + protected Menu calculateMenu = new Menu("Calculate"); + protected MenuItem selectAllSequenceMenuItem = new MenuItem("Select all"); + protected MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All"); + protected MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection"); + protected MenuItem remove2LeftMenuItem = new MenuItem(); + protected MenuItem remove2RightMenuItem = new MenuItem(); + protected MenuItem removeGappedColumnMenuItem = new MenuItem(); + protected MenuItem removeAllGapsMenuItem = new MenuItem(); + protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem(); + protected MenuItem sortPairwiseMenuItem = new MenuItem(); + protected MenuItem sortIDMenuItem = new MenuItem(); + protected MenuItem sortGroupMenuItem = new MenuItem(); + protected MenuItem removeRedundancyMenuItem = new MenuItem(); + protected MenuItem pairwiseAlignmentMenuItem = new MenuItem(); + protected MenuItem PCAMenuItem = new MenuItem(); + protected MenuItem averageDistanceTreeMenuItem = new MenuItem(); + protected MenuItem neighbourTreeMenuItem = new MenuItem(); + BorderLayout borderLayout1 = new BorderLayout(); + public Label statusBar = new Label(); + protected Menu outputTextboxMenu = new Menu(); + protected MenuItem clustalColour = new MenuItem(); + protected MenuItem zappoColour = new MenuItem(); + protected MenuItem taylorColour = new MenuItem(); + protected MenuItem hydrophobicityColour = new MenuItem(); + protected MenuItem helixColour = new MenuItem(); + protected MenuItem strandColour = new MenuItem(); + protected MenuItem turnColour = new MenuItem(); + protected MenuItem buriedColour = new MenuItem(); + protected MenuItem userDefinedColour = new MenuItem(); + protected MenuItem PIDColour = new MenuItem(); + protected MenuItem BLOSUM62Colour = new MenuItem(); + MenuItem njTreeBlosumMenuItem = new MenuItem(); + MenuItem avDistanceTreeBlosumMenuItem = new MenuItem(); + protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem(); + MenuItem overviewMenuItem = new MenuItem(); + protected MenuItem undoMenuItem = new MenuItem(); + protected MenuItem redoMenuItem = new MenuItem(); + protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); + MenuItem noColourmenuItem = new MenuItem(); + protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem(); + MenuItem findMenuItem = new MenuItem(); protected CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem(); - protected MenuItem nucleotideColour = new MenuItem(); - MenuItem deleteGroups = new MenuItem(); - MenuItem delete = new MenuItem(); - MenuItem copy = new MenuItem(); - MenuItem cut = new MenuItem(); - Menu pasteMenu = new Menu(); - MenuItem pasteNew = new MenuItem(); - MenuItem pasteThis = new MenuItem(); - protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem(); - protected MenuItem font = new MenuItem(); - protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem(); - protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem(); - protected CheckboxMenuItem scaleRight = new CheckboxMenuItem(); - MenuItem modifyPID = new MenuItem(); - MenuItem modifyConservation = new MenuItem(); - protected CheckboxMenuItem autoCalculate - = new CheckboxMenuItem("Autocalculate Consensus", true); - protected Menu sortByTreeMenu = new Menu(); - Menu sort = new Menu(); - Menu calculate = new Menu(); - MenuItem inputText = new MenuItem(); - Menu helpMenu = new Menu(); - MenuItem documentation = new MenuItem(); - MenuItem about = new MenuItem(); - protected CheckboxMenuItem seqLimits = new CheckboxMenuItem(); + protected MenuItem nucleotideColour = new MenuItem(); + MenuItem deleteGroups = new MenuItem(); + MenuItem delete = new MenuItem(); + MenuItem copy = new MenuItem(); + MenuItem cut = new MenuItem(); + Menu pasteMenu = new Menu(); + MenuItem pasteNew = new MenuItem(); + MenuItem pasteThis = new MenuItem(); + protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem(); + protected MenuItem font = new MenuItem(); + protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem(); + protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem(); + protected CheckboxMenuItem scaleRight = new CheckboxMenuItem(); + MenuItem modifyPID = new MenuItem(); + MenuItem modifyConservation = new MenuItem(); + protected CheckboxMenuItem autoCalculate + = new CheckboxMenuItem("Autocalculate Consensus", true); + protected Menu sortByTreeMenu = new Menu(); + Menu sort = new Menu(); + Menu calculate = new Menu(); + MenuItem inputText = new MenuItem(); + Menu helpMenu = new Menu(); + MenuItem documentation = new MenuItem(); + MenuItem about = new MenuItem(); + protected CheckboxMenuItem seqLimits = new CheckboxMenuItem(); Panel embeddedMenu; Label embeddedEdit; Label embeddedSelect; @@ -2064,176 +2283,179 @@ public void itemStateChanged(ItemEvent evt) Label embeddedCalculate; FlowLayout flowLayout1; - private void jbInit() throws Exception { + private void jbInit() + throws Exception + { - setMenuBar(alignFrameMenuBar); + setMenuBar(alignFrameMenuBar); - MenuItem item; + MenuItem item; - // dynamically fill save as menu with available formats - for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) - { + // dynamically fill save as menu with available formats + for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; + i++) + { - item = new MenuItem( jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); + item = new MenuItem(jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); - item.addActionListener(new java.awt.event.ActionListener() + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) { - public void actionPerformed(ActionEvent e) - { - outputText_actionPerformed(e); - } - }); - - outputTextboxMenu.add(item); - } - closeMenuItem.addActionListener(this); - loadApplication.addActionListener(this); - - loadTree.addActionListener(this); - loadAnnotations.addActionListener(this); - outputFeatures.addActionListener(this); - outputAnnotations.addActionListener(this); - selectAllSequenceMenuItem.addActionListener(this); - deselectAllSequenceMenuItem.addActionListener(this); - invertSequenceMenuItem.addActionListener(this); - remove2LeftMenuItem.setLabel("Remove Left"); - remove2LeftMenuItem.addActionListener(this); - remove2RightMenuItem.setLabel("Remove Right"); - remove2RightMenuItem.addActionListener(this); - removeGappedColumnMenuItem.setLabel("Remove Empty Columns"); - removeGappedColumnMenuItem.addActionListener(this); - removeAllGapsMenuItem.setLabel("Remove All Gaps"); - removeAllGapsMenuItem.addActionListener(this); - viewBoxesMenuItem.setLabel("Boxes"); - viewBoxesMenuItem.setState(true); - viewBoxesMenuItem.addItemListener(this); - viewTextMenuItem.setLabel("Text"); - viewTextMenuItem.setState(true); - viewTextMenuItem.addItemListener(this); - sortPairwiseMenuItem.setLabel("by Pairwise Identity"); - sortPairwiseMenuItem.addActionListener(this); - sortIDMenuItem.setLabel("by ID"); - sortIDMenuItem.addActionListener(this); - sortGroupMenuItem.setLabel("by Group"); - sortGroupMenuItem.addActionListener(this); - removeRedundancyMenuItem.setLabel("Remove Redundancy..."); - removeRedundancyMenuItem.addActionListener(this); - pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments..."); - pairwiseAlignmentMenuItem.addActionListener(this); - PCAMenuItem.setLabel("Principal Component Analysis"); - PCAMenuItem.addActionListener(this); - averageDistanceTreeMenuItem.setLabel( - "Average Distance Using % Identity"); - averageDistanceTreeMenuItem.addActionListener(this); - neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity"); - neighbourTreeMenuItem.addActionListener(this); - statusBar.setBackground(Color.white); - statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); - statusBar.setText("Status bar"); - outputTextboxMenu.setLabel("Output to Textbox"); - clustalColour.setLabel("Clustalx"); - - clustalColour.addActionListener(this); - zappoColour.setLabel("Zappo"); - zappoColour.addActionListener(this); - taylorColour.setLabel("Taylor"); - taylorColour.addActionListener(this); - hydrophobicityColour.setLabel("Hydrophobicity"); - hydrophobicityColour.addActionListener(this); - helixColour.setLabel("Helix Propensity"); - helixColour.addActionListener(this); - strandColour.setLabel("Strand Propensity"); - strandColour.addActionListener(this); - turnColour.setLabel("Turn Propensity"); - turnColour.addActionListener(this); - buriedColour.setLabel("Buried Index"); - buriedColour.addActionListener(this); - userDefinedColour.setLabel("User Defined..."); - userDefinedColour.addActionListener(this); - PIDColour.setLabel("Percentage Identity"); - PIDColour.addActionListener(this); - BLOSUM62Colour.setLabel("BLOSUM62 Score"); - BLOSUM62Colour.addActionListener(this); - avDistanceTreeBlosumMenuItem.setLabel( - "Average Distance Using BLOSUM62"); - avDistanceTreeBlosumMenuItem.addActionListener(this); - njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62"); - njTreeBlosumMenuItem.addActionListener(this); - annotationPanelMenuItem.setLabel("Show Annotations"); - annotationPanelMenuItem.addItemListener(this); - colourTextMenuItem.setLabel("Colour Text"); - colourTextMenuItem.addItemListener(this); - overviewMenuItem.setLabel("Overview Window"); - overviewMenuItem.addActionListener(this); - undoMenuItem.setEnabled(false); - undoMenuItem.setLabel("Undo"); - undoMenuItem.addActionListener(this); - redoMenuItem.setEnabled(false); - redoMenuItem.setLabel("Redo"); - redoMenuItem.addActionListener(this); - conservationMenuItem.setLabel("by Conservation"); - conservationMenuItem.addItemListener(this); - noColourmenuItem.setLabel("None"); - noColourmenuItem.addActionListener(this); - wrapMenuItem.setLabel("Wrap"); - wrapMenuItem.addItemListener(this); - renderGapsMenuItem.setLabel("Show Gaps"); - renderGapsMenuItem.setState(true); - renderGapsMenuItem.addItemListener(this); - findMenuItem.setLabel("Find..."); - findMenuItem.addActionListener(this); + outputText_actionPerformed(e); + } + }); + + outputTextboxMenu.add(item); + } + closeMenuItem.addActionListener(this); + loadApplication.addActionListener(this); + + loadTree.addActionListener(this); + loadAnnotations.addActionListener(this); + outputFeatures.addActionListener(this); + outputAnnotations.addActionListener(this); + selectAllSequenceMenuItem.addActionListener(this); + deselectAllSequenceMenuItem.addActionListener(this); + invertSequenceMenuItem.addActionListener(this); + remove2LeftMenuItem.setLabel("Remove Left"); + remove2LeftMenuItem.addActionListener(this); + remove2RightMenuItem.setLabel("Remove Right"); + remove2RightMenuItem.addActionListener(this); + removeGappedColumnMenuItem.setLabel("Remove Empty Columns"); + removeGappedColumnMenuItem.addActionListener(this); + removeAllGapsMenuItem.setLabel("Remove All Gaps"); + removeAllGapsMenuItem.addActionListener(this); + viewBoxesMenuItem.setLabel("Boxes"); + viewBoxesMenuItem.setState(true); + viewBoxesMenuItem.addItemListener(this); + viewTextMenuItem.setLabel("Text"); + viewTextMenuItem.setState(true); + viewTextMenuItem.addItemListener(this); + sortPairwiseMenuItem.setLabel("by Pairwise Identity"); + sortPairwiseMenuItem.addActionListener(this); + sortIDMenuItem.setLabel("by ID"); + sortIDMenuItem.addActionListener(this); + sortGroupMenuItem.setLabel("by Group"); + sortGroupMenuItem.addActionListener(this); + removeRedundancyMenuItem.setLabel("Remove Redundancy..."); + removeRedundancyMenuItem.addActionListener(this); + pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments..."); + pairwiseAlignmentMenuItem.addActionListener(this); + PCAMenuItem.setLabel("Principal Component Analysis"); + PCAMenuItem.addActionListener(this); + averageDistanceTreeMenuItem.setLabel( + "Average Distance Using % Identity"); + averageDistanceTreeMenuItem.addActionListener(this); + neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity"); + neighbourTreeMenuItem.addActionListener(this); + statusBar.setBackground(Color.white); + statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); + statusBar.setText("Status bar"); + outputTextboxMenu.setLabel("Output to Textbox"); + clustalColour.setLabel("Clustalx"); + + clustalColour.addActionListener(this); + zappoColour.setLabel("Zappo"); + zappoColour.addActionListener(this); + taylorColour.setLabel("Taylor"); + taylorColour.addActionListener(this); + hydrophobicityColour.setLabel("Hydrophobicity"); + hydrophobicityColour.addActionListener(this); + helixColour.setLabel("Helix Propensity"); + helixColour.addActionListener(this); + strandColour.setLabel("Strand Propensity"); + strandColour.addActionListener(this); + turnColour.setLabel("Turn Propensity"); + turnColour.addActionListener(this); + buriedColour.setLabel("Buried Index"); + buriedColour.addActionListener(this); + userDefinedColour.setLabel("User Defined..."); + userDefinedColour.addActionListener(this); + PIDColour.setLabel("Percentage Identity"); + PIDColour.addActionListener(this); + BLOSUM62Colour.setLabel("BLOSUM62 Score"); + BLOSUM62Colour.addActionListener(this); + avDistanceTreeBlosumMenuItem.setLabel( + "Average Distance Using BLOSUM62"); + avDistanceTreeBlosumMenuItem.addActionListener(this); + njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62"); + njTreeBlosumMenuItem.addActionListener(this); + annotationPanelMenuItem.setLabel("Show Annotations"); + annotationPanelMenuItem.addItemListener(this); + colourTextMenuItem.setLabel("Colour Text"); + colourTextMenuItem.addItemListener(this); + overviewMenuItem.setLabel("Overview Window"); + overviewMenuItem.addActionListener(this); + undoMenuItem.setEnabled(false); + undoMenuItem.setLabel("Undo"); + undoMenuItem.addActionListener(this); + redoMenuItem.setEnabled(false); + redoMenuItem.setLabel("Redo"); + redoMenuItem.addActionListener(this); + conservationMenuItem.setLabel("by Conservation"); + conservationMenuItem.addItemListener(this); + noColourmenuItem.setLabel("None"); + noColourmenuItem.addActionListener(this); + wrapMenuItem.setLabel("Wrap"); + wrapMenuItem.addItemListener(this); + renderGapsMenuItem.setLabel("Show Gaps"); + renderGapsMenuItem.setState(true); + renderGapsMenuItem.addItemListener(this); + findMenuItem.setLabel("Find..."); + findMenuItem.addActionListener(this); abovePIDThreshold.setLabel("Above Identity Threshold"); - abovePIDThreshold.addItemListener(this); - nucleotideColour.setLabel("Nucleotide"); - nucleotideColour.addActionListener(this); - deleteGroups.setLabel("Undefine Groups"); - deleteGroups.addActionListener(this); - copy.setLabel("Copy"); - copy.addActionListener(this); - cut.setLabel("Cut"); - cut.addActionListener(this); - delete.setLabel("Delete"); - delete.addActionListener(this); - pasteMenu.setLabel("Paste"); - pasteNew.setLabel("To New Alignment"); - pasteNew.addActionListener(this); - pasteThis.setLabel("Add To This Alignment"); - pasteThis.addActionListener(this); - applyToAllGroups.setLabel("Apply Colour To All Groups"); - applyToAllGroups.setState(true); - applyToAllGroups.addItemListener(this); - font.setLabel("Font..."); - font.addActionListener(this); - scaleAbove.setLabel("Scale Above"); - scaleAbove.setState(true); - scaleAbove.setEnabled(false); - scaleAbove.addItemListener(this); - scaleLeft.setEnabled(false); - scaleLeft.setState(true); - scaleLeft.setLabel("Scale Left"); - scaleLeft.addItemListener(this); - scaleRight.setEnabled(false); - scaleRight.setState(true); - scaleRight.setLabel("Scale Right"); - scaleRight.addItemListener(this); - modifyPID.setLabel("Modify Identity Threshold..."); - modifyPID.addActionListener(this); - modifyConservation.setLabel("Modify Conservation Threshold..."); - modifyConservation.addActionListener(this); - sortByTreeMenu.setLabel("By Tree Order"); - sort.setLabel("Sort"); - calculate.setLabel("Calculate Tree"); - autoCalculate.addItemListener(this); - inputText.setLabel("Input from textbox"); - inputText.addActionListener(this); - - helpMenu.setLabel("Help"); - documentation.setLabel("Documentation"); - documentation.addActionListener(this); - - about.setLabel("About..."); - about.addActionListener(this); - seqLimits.setState(true); + abovePIDThreshold.addItemListener(this); + nucleotideColour.setLabel("Nucleotide"); + nucleotideColour.addActionListener(this); + deleteGroups.setLabel("Undefine Groups"); + deleteGroups.addActionListener(this); + copy.setLabel("Copy"); + copy.addActionListener(this); + cut.setLabel("Cut"); + cut.addActionListener(this); + delete.setLabel("Delete"); + delete.addActionListener(this); + pasteMenu.setLabel("Paste"); + pasteNew.setLabel("To New Alignment"); + pasteNew.addActionListener(this); + pasteThis.setLabel("Add To This Alignment"); + pasteThis.addActionListener(this); + applyToAllGroups.setLabel("Apply Colour To All Groups"); + applyToAllGroups.setState(true); + applyToAllGroups.addItemListener(this); + font.setLabel("Font..."); + font.addActionListener(this); + scaleAbove.setLabel("Scale Above"); + scaleAbove.setState(true); + scaleAbove.setEnabled(false); + scaleAbove.addItemListener(this); + scaleLeft.setEnabled(false); + scaleLeft.setState(true); + scaleLeft.setLabel("Scale Left"); + scaleLeft.addItemListener(this); + scaleRight.setEnabled(false); + scaleRight.setState(true); + scaleRight.setLabel("Scale Right"); + scaleRight.addItemListener(this); + modifyPID.setLabel("Modify Identity Threshold..."); + modifyPID.addActionListener(this); + modifyConservation.setLabel("Modify Conservation Threshold..."); + modifyConservation.addActionListener(this); + sortByTreeMenu.setLabel("By Tree Order"); + sort.setLabel("Sort"); + calculate.setLabel("Calculate Tree"); + autoCalculate.addItemListener(this); + inputText.setLabel("Input from textbox"); + inputText.addActionListener(this); + + helpMenu.setLabel("Help"); + documentation.setLabel("Documentation"); + documentation.addActionListener(this); + + about.setLabel("About..."); + about.addActionListener(this); + seqLimits.setState(true); seqLimits.setLabel("Show Sequence Limits"); seqLimits.addItemListener(this); featureSettings.setLabel("Feature Settings..."); @@ -2261,41 +2483,43 @@ public void itemStateChanged(ItemEvent evt) newView.setLabel("New View"); newView.addActionListener(this); alignFrameMenuBar.add(fileMenu); - alignFrameMenuBar.add(editMenu); + alignFrameMenuBar.add(editMenu); alignFrameMenuBar.add(selectMenu); alignFrameMenuBar.add(viewMenu); alignFrameMenuBar.add(formatMenu); alignFrameMenuBar.add(colourMenu); - alignFrameMenuBar.add(calculateMenu); - alignFrameMenuBar.add(helpMenu); - - fileMenu.add(inputText); - fileMenu.add(loadTree); - fileMenu.add(loadAnnotations); - - fileMenu.addSeparator(); - fileMenu.add(outputTextboxMenu); - fileMenu.add(outputFeatures); - fileMenu.add(outputAnnotations); - - if(jalviewServletURL!=null) - fileMenu.add(loadApplication); - - fileMenu.addSeparator(); - fileMenu.add(closeMenuItem); - - editMenu.add(undoMenuItem); - editMenu.add(redoMenuItem); - editMenu.add(cut); - editMenu.add(copy); - editMenu.add(pasteMenu); - editMenu.add(delete); - editMenu.addSeparator(); - editMenu.add(remove2LeftMenuItem); - editMenu.add(remove2RightMenuItem); - editMenu.add(removeGappedColumnMenuItem); - editMenu.add(removeAllGapsMenuItem); - editMenu.add(removeRedundancyMenuItem); + alignFrameMenuBar.add(calculateMenu); + alignFrameMenuBar.add(helpMenu); + + fileMenu.add(inputText); + fileMenu.add(loadTree); + fileMenu.add(loadAnnotations); + + fileMenu.addSeparator(); + fileMenu.add(outputTextboxMenu); + fileMenu.add(outputFeatures); + fileMenu.add(outputAnnotations); + + if (jalviewServletURL != null) + { + fileMenu.add(loadApplication); + } + + fileMenu.addSeparator(); + fileMenu.add(closeMenuItem); + + editMenu.add(undoMenuItem); + editMenu.add(redoMenuItem); + editMenu.add(cut); + editMenu.add(copy); + editMenu.add(pasteMenu); + editMenu.add(delete); + editMenu.addSeparator(); + editMenu.add(remove2LeftMenuItem); + editMenu.add(remove2RightMenuItem); + editMenu.add(removeGappedColumnMenuItem); + editMenu.add(removeAllGapsMenuItem); + editMenu.add(removeRedundancyMenuItem); viewMenu.add(newView); viewMenu.addSeparator(); viewMenu.add(menu1); @@ -2303,50 +2527,50 @@ public void itemStateChanged(ItemEvent evt) viewMenu.addSeparator(); viewMenu.add(annotationPanelMenuItem); viewMenu.addSeparator(); - viewMenu.add(sequenceFeatures); - viewMenu.add(featureSettings); + viewMenu.add(sequenceFeatures); + viewMenu.add(featureSettings); viewMenu.addSeparator(); - viewMenu.add(overviewMenuItem); - colourMenu.add(applyToAllGroups); - colourMenu.addSeparator(); - colourMenu.add(noColourmenuItem); - colourMenu.add(clustalColour); - colourMenu.add(BLOSUM62Colour); - colourMenu.add(PIDColour); - colourMenu.add(zappoColour); - colourMenu.add(taylorColour); - colourMenu.add(hydrophobicityColour); - colourMenu.add(helixColour); - colourMenu.add(strandColour); - colourMenu.add(turnColour); - colourMenu.add(buriedColour); - colourMenu.add(nucleotideColour); - colourMenu.add(userDefinedColour); - colourMenu.addSeparator(); - colourMenu.add(conservationMenuItem); - colourMenu.add(modifyConservation); - colourMenu.add(abovePIDThreshold); - colourMenu.add(modifyPID); + viewMenu.add(overviewMenuItem); + colourMenu.add(applyToAllGroups); + colourMenu.addSeparator(); + colourMenu.add(noColourmenuItem); + colourMenu.add(clustalColour); + colourMenu.add(BLOSUM62Colour); + colourMenu.add(PIDColour); + colourMenu.add(zappoColour); + colourMenu.add(taylorColour); + colourMenu.add(hydrophobicityColour); + colourMenu.add(helixColour); + colourMenu.add(strandColour); + colourMenu.add(turnColour); + colourMenu.add(buriedColour); + colourMenu.add(nucleotideColour); + colourMenu.add(userDefinedColour); + colourMenu.addSeparator(); + colourMenu.add(conservationMenuItem); + colourMenu.add(modifyConservation); + colourMenu.add(abovePIDThreshold); + colourMenu.add(modifyPID); colourMenu.add(annotationColour); calculateMenu.add(sort); - calculateMenu.add(calculate); - calculateMenu.addSeparator(); - calculateMenu.add(pairwiseAlignmentMenuItem); - calculateMenu.add(PCAMenuItem); - calculateMenu.add(autoCalculate); - this.add(statusBar, BorderLayout.SOUTH); - pasteMenu.add(pasteNew); - pasteMenu.add(pasteThis); - sort.add(sortIDMenuItem); - sort.add(sortByTreeMenu); - sort.add(sortGroupMenuItem); - sort.add(sortPairwiseMenuItem); - calculate.add(averageDistanceTreeMenuItem); - calculate.add(neighbourTreeMenuItem); - calculate.add(avDistanceTreeBlosumMenuItem); - calculate.add(njTreeBlosumMenuItem); - helpMenu.add(documentation); - helpMenu.add(about); + calculateMenu.add(calculate); + calculateMenu.addSeparator(); + calculateMenu.add(pairwiseAlignmentMenuItem); + calculateMenu.add(PCAMenuItem); + calculateMenu.add(autoCalculate); + this.add(statusBar, BorderLayout.SOUTH); + pasteMenu.add(pasteNew); + pasteMenu.add(pasteThis); + sort.add(sortIDMenuItem); + sort.add(sortByTreeMenu); + sort.add(sortGroupMenuItem); + sort.add(sortPairwiseMenuItem); + calculate.add(averageDistanceTreeMenuItem); + calculate.add(neighbourTreeMenuItem); + calculate.add(avDistanceTreeBlosumMenuItem); + calculate.add(njTreeBlosumMenuItem); + helpMenu.add(documentation); + helpMenu.add(about); menu1.add(showColumns); menu1.add(showSeqs); menu2.add(hideColumns); @@ -2420,18 +2644,17 @@ public void itemStateChanged(ItemEvent evt) viewport.applet.add(embeddedMenu, BorderLayout.NORTH); viewport.applet.add(statusBar, BorderLayout.SOUTH); - alignPanel.setSize(viewport.applet.getSize().width, viewport.applet.getSize().height + alignPanel.setSize(viewport.applet.getSize().width, + viewport.applet.getSize().height - embeddedMenu.HEIGHT - statusBar.HEIGHT); - viewport.applet.add(alignPanel, BorderLayout.CENTER); - viewport.applet.validate(); + viewport.applet.add(alignPanel, BorderLayout.CENTER); + viewport.applet.validate(); } - - PopupMenu filePopup, editPopup, searchPopup, - viewPopup, formatPopup, colourPopup, calculatePopup, helpPopup; + viewPopup, formatPopup, colourPopup, calculatePopup, helpPopup; MenuItem featureSettings = new MenuItem(); CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem(); MenuItem annotationColour = new MenuItem(); @@ -2449,36 +2672,36 @@ public void itemStateChanged(ItemEvent evt) public void mousePressed(MouseEvent evt) { PopupMenu popup = null; - Label source = (Label)evt.getSource(); - if(source==embeddedFile) + Label source = (Label) evt.getSource(); + if (source == embeddedFile) { popup = filePopup = genPopupMenu(filePopup, fileMenu); } - else if(source==embeddedEdit) + else if (source == embeddedEdit) { popup = editPopup = genPopupMenu(editPopup, editMenu); } - else if(source==embeddedSelect) + else if (source == embeddedSelect) { popup = searchPopup = genPopupMenu(searchPopup, selectMenu); } - else if(source==embeddedView) + else if (source == embeddedView) { popup = viewPopup = genPopupMenu(viewPopup, viewMenu); } - else if (source ==embeddedFormat) + else if (source == embeddedFormat) { popup = formatPopup = genPopupMenu(formatPopup, formatMenu); } - else if(source==embeddedColour) + else if (source == embeddedColour) { popup = colourPopup = genPopupMenu(colourPopup, colourMenu); } - else if(source==embeddedCalculate) + else if (source == embeddedCalculate) { popup = calculatePopup = genPopupMenu(calculatePopup, calculateMenu); } - else if(source==embeddedHelp) + else if (source == embeddedHelp) { popup = helpPopup = genPopupMenu(helpPopup, helpMenu); } @@ -2491,13 +2714,13 @@ public void itemStateChanged(ItemEvent evt) PopupMenu genPopupMenu(PopupMenu popup, Menu original) { - if(popup!=null) + if (popup != null) { return popup; } popup = new PopupMenu(); int m, mSize = original.getItemCount(); - for(m=0; m0) + if (alignment.getHiddenSequences().getSize() > 0) { - if(selectionGroup==null) + if (selectionGroup == null) { selectionGroup = new SequenceGroup(); - selectionGroup.setEndRes(alignment.getWidth()-1); + selectionGroup.setEndRes(alignment.getWidth() - 1); } Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences); - for(int t=0; t

Title:

* @@ -35,241 +34,283 @@ import java.util.*; */ public class AlignmentOrder { - // JBPNote : this method would return a vector containing all sequences in seqset - // with those also contained in order at the beginning of the vector in the order - // given by order. AlignmentSorter.vectorSubsetToArray already does this, but that method - // should be here for completeness. + // JBPNote : this method would return a vector containing all sequences in seqset + // with those also contained in order at the beginning of the vector in the order + // given by order. AlignmentSorter.vectorSubsetToArray already does this, but that method + // should be here for completeness. - /* public Vector getOrder(AlignmentI seqset) - { - Vector perm = new Vector(seqset.getHeight()); - for (i=0, o = 0, n=seqset.getHeight(), p = Order.size(); i -1) { - this.Order = Order; + Order.setElementAt(newref, found); } + return found > -1; + } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Vector getOrder() + /** + * Exact equivalence of two AlignmentOrders + * @param o + * @return true if o orders the same sequenceI objects in the same way + */ + public boolean equals(AlignmentOrder o) + { + return equals(o, true); + } + + /** + * Exact equivalence of two AlignmentOrders + * // TODO: Weak SequenceI equivalence - will throw Error at moment + * @param o + * @param identity - false - use weak equivalence (refers to same or different parts of same sequence) + * @return true if o orders equivalent sequenceI objects in the same way + */ + public boolean equals(AlignmentOrder o, boolean identity) + { + if (o != this) { - return Order; - } - /** - * replaces oldref with newref in the alignment order. - * @param oldref - * @param newref - * @return true if oldref was contained in order and replaced with newref - */ - public boolean updateSequence(SequenceI oldref, SequenceI newref) { - int found=Order.indexOf(oldref); - if (found>-1) { - Order.setElementAt(newref, found); + if (o == null) + { + return false; } - return found>-1; - } - /** - * Exact equivalence of two AlignmentOrders - * @param o - * @return true if o orders the same sequenceI objects in the same way - */ - public boolean equals(AlignmentOrder o) { - return equals(o, true); - } - /** - * Exact equivalence of two AlignmentOrders - * // TODO: Weak SequenceI equivalence - will throw Error at moment - * @param o - * @param identity - false - use weak equivalence (refers to same or different parts of same sequence) - * @return true if o orders equivalent sequenceI objects in the same way - */ - public boolean equals(AlignmentOrder o, boolean identity) { - if (o!=this) { - if (o==null) - return false; - if (Order!=null && o.Order!=null && Order.size()==o.Order.size()) { - if (!identity) { - throw new Error("Weak sequenceI equivalence not yet implemented."); - } else { - for (int i=0,j=o.Order.size(); iOrder.size()) { - c = o.Order; - s = Order; - } else { - c = Order; - s = o.Order; - } - if (!identity) { - throw new Error("Weak sequenceI equivalence not yet implemented."); - } else { - // test if c contains s and order in s is conserved in c - int last=-1; - for (int i=0,j=s.size(); ilast) { - last=pos; - } else - return false; + return true; + } + + /** + * Consistency test for alignmentOrders + * @param o + * @return true if o contains or is contained by this and the common SequenceI objects are ordered in the same way + */ + public boolean isConsistent(AlignmentOrder o) + { + return isConsistent(o, true); + } + + /** + * Consistency test for alignmentOrders + * @param o + * // TODO: Weak SequenceI equivalence - will throw Error at moment + * @param identity - false - use weak equivalence (refers to same or different parts of same sequence) + * @return true if o contains or is contained by this and the common SequenceI objects are ordered in the same way + */ + public boolean isConsistent(AlignmentOrder o, boolean identity) + { + if (o != this) + { + if (o == null) + { + return false; + } + if (Order != null && o.Order != null) + { + Vector c, s; + if (o.Order.size() > Order.size()) + { + c = o.Order; + s = Order; + } + else + { + c = Order; + s = o.Order; + } + if (!identity) + { + throw new Error("Weak sequenceI equivalence not yet implemented."); + } + else + { + // test if c contains s and order in s is conserved in c + int last = -1; + for (int i = 0, j = s.size(); i < j; i++) + { + int pos = c.indexOf(s.elementAt(i)); // JBPNote - optimize by incremental position search + if (pos > last) + { + last = pos; + } + else + { + return false; } } - } else - return false; + } + } + else + { + return false; } - return true; } - /** - * AlignmentOrder - * - * @param orderThis AlignmentI - * @param byThat AlignmentI - */ + return true; + } + /** + * AlignmentOrder + * + * @param orderThis AlignmentI + * @param byThat AlignmentI + */ - /* public AlignmentOrder(AlignmentI orderThis, AlignmentI byThat) - { - // Vector is an ordering of this alignment using the order of sequence objects in byThat, - // where ids and unaligned sequences must match + /* public AlignmentOrder(AlignmentI orderThis, AlignmentI byThat) + { + // Vector is an ordering of this alignment using the order of sequence objects in byThat, + // where ids and unaligned sequences must match - } */ + } */ } diff --git a/src/jalview/datamodel/AlignmentView.java b/src/jalview/datamodel/AlignmentView.java index 8b86a82..79e0ba2 100644 --- a/src/jalview/datamodel/AlignmentView.java +++ b/src/jalview/datamodel/AlignmentView.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,8 +18,6 @@ */ package jalview.datamodel; - - /** *

Title:

* @@ -34,30 +32,34 @@ package jalview.datamodel; */ public class AlignmentView { - /** - * Transient object compactly representing a 'view' of an alignment - with discontinuities marked. - */ - private SeqCigar[] sequences = null; + /** + * Transient object compactly representing a 'view' of an alignment - with discontinuities marked. + */ + private SeqCigar[] sequences = null; private int[] contigs = null; - private int width=0; - private int firstCol=0; + private int width = 0; + private int firstCol = 0; public AlignmentView(CigarArray seqcigararray) { if (!seqcigararray.isSeqCigarArray()) + { throw new Error("Implementation Error - can only make an alignment view from a CigarArray of sequences."); + } //contigs = seqcigararray.applyDeletions(); contigs = seqcigararray.getDeletedRegions(); sequences = seqcigararray.getSeqCigarArray(); width = seqcigararray.getWidth(); // visible width } + /** * Create an alignmentView where the first column corresponds with the 'firstcol' column of some reference alignment * @param sdata * @param firstcol */ - public AlignmentView(CigarArray sdata, int firstcol) { + public AlignmentView(CigarArray sdata, int firstcol) + { this(sdata); - firstCol=firstcol; + firstCol = firstcol; } public void setSequences(SeqCigar[] sequences) @@ -74,6 +76,7 @@ public class AlignmentView { return sequences; } + /** * @see CigarArray.getDeletedRegions * @return int[] { vis_start, sym_start, length } @@ -82,16 +85,22 @@ public class AlignmentView { return contigs; } + /** * get the full alignment and a columnselection object marking the hidden regions * @param gapCharacter char * @return Object[] { SequenceI[], ColumnSelection} */ - public Object[] getAlignmentAndColumnSelection(char gapCharacter) { + public Object[] getAlignmentAndColumnSelection(char gapCharacter) + { ColumnSelection colsel = new ColumnSelection(); - return new Object[] { SeqCigar.createAlignmentSequences(sequences, gapCharacter, colsel, contigs), colsel}; + return new Object[] + { + SeqCigar.createAlignmentSequences(sequences, gapCharacter, colsel, + contigs), colsel}; } + /** * getSequenceStrings * @@ -100,8 +109,9 @@ public class AlignmentView */ public String[] getSequenceStrings(char c) { - String[] seqs=new String[sequences.length]; - for (int n=0; n 0) { int start = 0; @@ -198,20 +218,25 @@ public class AlignmentView } return smsa; } + /** * return full msa and hidden regions with visible blocks replaced with new sub alignments * @param nvismsa SequenceI[][] * @param orders AlignmentOrder[] corresponding to each SequenceI[] block. * @return Object[] */ - public Object[] getUpdatedView(SequenceI[][] nvismsa, AlignmentOrder[] orders, char gapCharacter) { + public Object[] getUpdatedView(SequenceI[][] nvismsa, AlignmentOrder[] orders, + char gapCharacter) + { if (sequences == null || width <= 0) { throw new Error("empty view cannot be updated."); } if (nvismsa == null) + { throw new Error( "nvismsa==null. use getAlignmentAndColumnSelection() instead."); + } if (contigs != null && contigs.length > 0) { SequenceI[] alignment = new SequenceI[sequences.length]; @@ -231,10 +256,15 @@ public class AlignmentView if (nvismsa[j] != null) { SequenceI mseq[] = nvismsa[j]; - AlignmentOrder order=(orders==null) ? null : orders[j]; + AlignmentOrder order = (orders == null) ? null : orders[j]; j++; - if (mseq.length!=sequences.length) - throw new Error("Mismatch between number of sequences in block "+j+" ("+mseq.length+") and the original view ("+sequences.length+")"); + if (mseq.length != sequences.length) + { + throw new Error( + "Mismatch between number of sequences in block " + j + " (" + + mseq.length + ") and the original view (" + + sequences.length + ")"); + } swidth = mseq[0].getLength(); // JBPNote: could ensure padded here. for (int s = 0; s < mseq.length; s++) { @@ -250,7 +280,8 @@ public class AlignmentView { alignment[s].setEnd(mseq[s].getEnd()); } - if (order!=null) { + if (order != null) + { order.updateSequence(mseq[s], alignment[s]); } } @@ -264,8 +295,9 @@ public class AlignmentView // recover input data for (int s = 0; s < sequences.length; s++) { - SequenceI oseq = sequences[s].getSeq(gapCharacter).getSubSequence(start, - contigs[contig + 1]); + SequenceI oseq = sequences[s].getSeq(gapCharacter). + getSubSequence(start, + contigs[contig + 1]); if (swidth < oseq.getLength()) { swidth = oseq.getLength(); @@ -295,7 +327,8 @@ public class AlignmentView // add hidden segment to right of next region for (int s = 0; s < sequences.length; s++) { - SequenceI hseq = sequences[s].getSeq(gapCharacter).getSubSequence(contigs[contig + + SequenceI hseq = sequences[s].getSeq(gapCharacter).getSubSequence( + contigs[contig + 1], start); if (alignment[s] == null) { @@ -322,7 +355,7 @@ public class AlignmentView if (nvismsa[j] != null) { SequenceI mseq[] = nvismsa[j]; - AlignmentOrder order = (orders!=null) ? orders[j] : null; + AlignmentOrder order = (orders != null) ? orders[j] : null; swidth = mseq[0].getLength(); for (int s = 0; s < mseq.length; s++) { @@ -338,7 +371,8 @@ public class AlignmentView { alignment[s].setEnd(mseq[s].getEnd()); } - if (order!=null) { + if (order != null) + { order.updateSequence(mseq[s], alignment[s]); } } @@ -354,8 +388,9 @@ public class AlignmentView // recover input data for (int s = 0; s < sequences.length; s++) { - SequenceI oseq = sequences[s].getSeq(gapCharacter).getSubSequence(start, - owidth + 1); + SequenceI oseq = sequences[s].getSeq(gapCharacter). + getSubSequence(start, + owidth + 1); if (swidth < oseq.getLength()) { swidth = oseq.getLength(); @@ -385,22 +420,37 @@ public class AlignmentView } } } - return new Object[] { alignment, columnselection}; - } else { - if (nvismsa.length!=1) - throw new Error("Mismatch between visible blocks to update and number of contigs in view (contigs=0,blocks="+nvismsa.length); - if (nvismsa[0]!=null) - return new Object[] { nvismsa[0], new ColumnSelection()}; + return new Object[] + { + alignment, columnselection}; + } + else + { + if (nvismsa.length != 1) + { + throw new Error("Mismatch between visible blocks to update and number of contigs in view (contigs=0,blocks=" + + nvismsa.length); + } + if (nvismsa[0] != null) + { + return new Object[] + { + nvismsa[0], new ColumnSelection()}; + } else + { return getAlignmentAndColumnSelection(gapCharacter); + } } } + /** * returns simple array of start end positions of visible range on alignment. * vis_start and vis_end are inclusive - use SequenceI.getSubSequence(vis_start, vis_end+1) to recover visible sequence from underlying alignment. * @return int[] { start_i, end_i } for 1 0) { int start = 0; @@ -419,33 +469,41 @@ public class AlignmentView { nvis++; } - int viscontigs[] = new int[nvis*2]; - nvis=0; - start=0; - for (int contig=0; contig 0) { viscontigs[nvis] = start; - viscontigs[nvis+1]=contigs[contig+1]-1; // end is inclusive - nvis+=2; + viscontigs[nvis + 1] = contigs[contig + 1] - 1; // end is inclusive + nvis += 2; } start = contigs[contig + 1] + contigs[contig + 2]; } - if (start 20) - { - aanum = 20; - } - - dbinary[(i * nores) + aanum] = 1.0; - } - } - /** - * ancode using substitution matrix given in matrix - * @param matrix - */ - public void matrixEncode(ScoreMatrix matrix) { - matrixEncode(matrix.isDNA()?ResidueProperties.nucleotideIndex: ResidueProperties.aaIndex, matrix.getMatrix()); + int aanum = 20; + + try + { + aanum = ResidueProperties.aaIndex[getCharAt(i)]; + } + catch (NullPointerException e) + { + aanum = 20; + } + + if (aanum > 20) + { + aanum = 20; + } + + dbinary[ (i * nores) + aanum] = 1.0; } - /** - * DOCUMENT ME! - */ - public void blosumEncode() + } + + /** + * ancode using substitution matrix given in matrix + * @param matrix + */ + public void matrixEncode(ScoreMatrix matrix) + { + matrixEncode(matrix.isDNA() ? ResidueProperties.nucleotideIndex : + ResidueProperties.aaIndex, matrix.getMatrix()); + } + + /** + * DOCUMENT ME! + */ + public void blosumEncode() + { + matrixEncode(ResidueProperties.aaIndex, ResidueProperties.getBLOSUM62()); + } + + private void matrixEncode(int[] aaIndex, int[][] matrix) + { + // Set all matrix to 0 + dbinary = new double[getSequence().length * 21]; + + int nores = 21; + + //for (int i = 0; i < dbinary.length; i++) { + // dbinary[i] = 0.0; + //} + for (int i = 0; i < getSequence().length; i++) { - matrixEncode(ResidueProperties.aaIndex, ResidueProperties.getBLOSUM62()); + int aanum = 20; + + try + { + aanum = aaIndex[getCharAt(i)]; + } + catch (NullPointerException e) + { + aanum = 20; + } + + if (aanum > 20) + { + aanum = 20; + } + + // Do the blosum thing + + for (int j = 0; j < 20; j++) + { + dbinary[ (i * nores) + j] = matrix[aanum][j]; + } } - private void matrixEncode(int[] aaIndex, int[][] matrix) { - // Set all matrix to 0 - dbinary = new double[getSequence().length * 21]; - - int nores = 21; - - //for (int i = 0; i < dbinary.length; i++) { - // dbinary[i] = 0.0; - //} - for (int i = 0; i < getSequence().length; i++) - { - int aanum = 20; - - try - { - aanum = aaIndex[getCharAt(i)]; - } - catch (NullPointerException e) - { - aanum = 20; - } - - if (aanum > 20) - { - aanum = 20; - } - - // Do the blosum thing - - for (int j = 0; j < 20; j++) - { - dbinary[(i * nores) + j] = matrix[aanum][j]; - } - } - } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String toBinaryString() + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String toBinaryString() + { + String out = ""; + + for (int i = 0; i < binary.length; i++) { - String out = ""; - - for (int i = 0; i < binary.length; i++) - { - out += (new Integer(binary[i])).toString(); + out += (new Integer(binary[i])).toString(); - if (i < (binary.length - 1)) - { - out += " "; - } - } - - return out; + if (i < (binary.length - 1)) + { + out += " "; + } } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public double[] getDBinary() - { - return dbinary; - } + return out; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public double[] getDBinary() + { + return dbinary; + } } diff --git a/src/jalview/datamodel/CigarArray.java b/src/jalview/datamodel/CigarArray.java index 9b60e56..c17e01e 100644 --- a/src/jalview/datamodel/CigarArray.java +++ b/src/jalview/datamodel/CigarArray.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,19 +18,21 @@ */ package jalview.datamodel; -public class CigarArray extends CigarBase +public class CigarArray + extends CigarBase { - /** - * Do CIGAR operations on a set of sequences from many other cigars - * BAD THINGS WILL HAPPEN IF A CIGARARRAY IS PASSED TO A CIGARARRAY - * or a CIGARCIGAR is given a CIGARARRAY to insert gaps into. - */ - /** - * array of subject cigars - */ - public CigarSimple refCigars[]=null; - private boolean seqcigararray=false; - private CigarArray() { + /** + * Do CIGAR operations on a set of sequences from many other cigars + * BAD THINGS WILL HAPPEN IF A CIGARARRAY IS PASSED TO A CIGARARRAY + * or a CIGARCIGAR is given a CIGARARRAY to insert gaps into. + */ + /** + * array of subject cigars + */ + public CigarSimple refCigars[] = null; + private boolean seqcigararray = false; + private CigarArray() + { super(); } @@ -42,12 +44,14 @@ public class CigarArray extends CigarBase { return seqcigararray; } + /** * Apply CIGAR operations to several cigars in parallel * will throw an error if any of cigar are actually CigarArrays. * @param cigar Cigar[] */ - public CigarArray(CigarSimple[] cigars) { + public CigarArray(CigarSimple[] cigars) + { super(); seqcigararray = true; if (cigars != null && cigars.length > 0) @@ -64,27 +68,34 @@ public class CigarArray extends CigarBase } } } + /** * @see Cigar.getSequenceAndDeletions * @param GapChar char * @return Object[][] */ - protected Object[][] getArrayofSequenceAndDeletions(char GapChar) { - if (refCigars == null || refCigars.length == 0 || length == 0) { - return null; + protected Object[][] getArrayofSequenceAndDeletions(char GapChar) + { + if (refCigars == null || refCigars.length == 0 || length == 0) + { + return null; + } + Object[][] sqanddels = new Object[refCigars.length][]; + for (int c = 0; c < refCigars.length; c++) + { + String refString = refCigars[c].getSequenceString(GapChar); + if (refString != null) + { + sqanddels[c] = getSequenceAndDeletions(refString, GapChar); } - Object[][] sqanddels = new Object[refCigars.length][]; - for (int c=0; c