- 博客(0)
- 资源 (10)
- 收藏
- 关注
Java 8函数式编程_最新版
Java 8函数式编程_最新版
Java 8函数式编程_最新版
Java 8函数式编程_最新版
Java 8函数式编程_最新版
Java 8函数式编程_最新版
2017-09-01
Oracle.PL.SQL程序设计_第五版_英文原版
Part I. Programming in PL/SQL
1. Introduction to PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
What Is PL/SQL? 3
The Origins of PL/SQL 4
The Early Years of PL/SQL 4
Improved Application Portability 5
Improved Execution Authority and Transaction Integrity 5
Humble Beginnings, Steady Improvement 6
So This Is PL/SQL 7
Integration with SQL 7
Control and Conditional Logic 8
When Things Go Wrong 9
About PL/SQL Versions 10
Oracle Database 11g New Features 12
Resources for PL/SQL Developers 17
The O’Reilly PL/SQL Series 17
PL/SQL on the Internet 18
Some Words of Advice 19
Don’t Be in Such a Hurry! 20
Don’t Be Afraid to Ask for Help 21
Take a Creative, Even Radical Approach 22
。。。。
2017-09-01
Oracle.PL.SQL程序设计_第五版
Oracle.PL.SQL程序设计_第五版
Part I. Programming in PL/SQL
1. Introduction to PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
What Is PL/SQL? 3
The Origins of PL/SQL 4
The Early Years of PL/SQL 4
Improved Application Portability 5
Improved Execution Authority and Transaction Integrity 5
Humble Beginnings, Steady Improvement 6
So This Is PL/SQL 7
Integration with SQL 7
Control and Conditional Logic 8
When Things Go Wrong 9
About PL/SQL Versions 10
Oracle Database 11g New Features 12
Resources for PL/SQL Developers 17
The O’Reilly PL/SQL Series 17
PL/SQL on the Internet 18
Some Words of Advice 19
Don’t Be in Such a Hurry! 20
Don’t Be Afraid to Ask for Help 21
Take a Creative, Even Radical Approach 22
2. Creating and Running PL/SQL Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Navigating the Database 23
Creating and Editing Source Code 24
SQL*Plus 25
Starting Up SQL*Plus 26
Running a SQL Statement 28
vii
Download at WoweBook.Com
Running a PL/SQL Program 28
Running a Script 30
What Is the “Current Directory”? 31
Other SQL*Plus Tasks 32
Error Handling in SQL*Plus 36
Why You Will Love and Hate SQL*Plus 37
Performing Essential PL/SQL Tasks 38
Creating a Stored Program 38
Executing a Stored Program 41
Showing Stored Programs 42
Managing Grants and Synonyms for Stored Programs 43
Dropping a Stored Program 44
Hiding the Source Code of a Stored Program 44
Editing Environments for PL/SQL 45
Calling PL/SQL from Other Languages 46
C: Using Oracle’s Precompiler (Pro*C) 47
Java: Using JDBC 48
Perl: Using Perl DBI and DBD::Oracle 49
PHP: Using Oracle Extensions 50
PL/SQL Server Pages 51
And Where Else? 52
3. Language Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
PL/SQL Block Structure 53
Anonymous Blocks 54
Named Blocks 56
Nested Blocks 57
Scope 58
Qualify all References to Variables and Columns in SQL Statements 59
Visibility 61
The PL/SQL Character Set 64
Identifiers 66
Reserved Words 68
Whitespace and Keywords 69
Literals 70
NULLs 71
Embedding Single Quotes Inside a Literal String 72
Numeric Literals 73
Boolean Literals 73
The Semicolon Delimiter 74
Comments 75
Single-Line Comment Syntax 75
Multiline Comment Syntax 75
viii | Table of Contents
Download at WoweBook.Com
The PRAGMA Keyword 76
Labels 77
Part II. PL/SQL Program Structure
4. Conditional and Sequential Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
IF Statements 81
The IF-THEN Combination 82
The IF-THEN-ELSE Combination 84
The IF-THEN-ELSIF Combination 85
Avoiding IF Syntax Gotchas 86
Nested IF Statements 88
Short-Circuit Evaluation 89
CASE Statements and Expressions 90
Simple CASE Statements 91
Searched CASE Statements 93
Nested CASE Statements 95
CASE Expressions 95
The GOTO Statement 97
The NULL Statement 98
Improving Program Readability 99
Using NULL After a Label 99
5. Iterative Processing with Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Loop Basics 101
Examples of Different Loops 102
Structure of PL/SQL Loops 103
The Simple Loop 104
Terminating a Simple Loop: EXIT and EXIT WHEN 105
Emulating a REPEAT UNTIL Loop 106
The Intentionally Infinite Loop 106
The WHILE Loop 108
The Numeric FOR Loop 109
Rules for Numeric FOR Loops 110
Examples of Numeric FOR Loops 111
Handling Nontrivial Increments 112
The Cursor FOR Loop 112
Example of Cursor FOR Loops 114
Loop Labels 115
The CONTINUE Statement 116
Tips for Iterative Processing 119
Use Understandable Names for Loop Indexes 119
Table of Contents | ix
Download at WoweBook.Com
The Proper Way to Say Goodbye 120
Obtaining Information About FOR Loop Execution 121
SQL Statement as Loop 122
6. Exception Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Exception-Handling Concepts and Terminology 125
Defining Exceptions 127
Declaring Named Exceptions 128
Associating Exception Names with Error Codes 129
About Named System Exceptions 132
Scope of an Exception 134
Raising Exceptions 135
The RAISE Statement 136
Using RAISE_APPLICATION_ERROR 137
Handling Exceptions 138
Built-in Error Functions 139
Combining Multiple Exceptions in a Single Handler 144
Unhandled Exceptions 145
Propagation of Unhandled Exceptions 145
Continuing Past Exceptions 148
Writing WHEN OTHERS Handling Code 150
Building an Effective Error Management Architecture 152
Decide on Your Error Management Strategy 153
Standardize Handling of Different Types of Exceptions 154
Organize Use of Application-Specific Error Codes 157
Use Standardized Error Management Programs 157
Work with Your Own Exception “Objects” 159
Create Standard Templates for Common Error Handling 162
Making the Most of PL/SQL Error Management 164
Part III. PL/SQL Program Data
7. Working with Program Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Naming Your Program Data 167
Overview of PL/SQL Datatypes 169
Character Data 170
Numbers 170
Dates, Timestamps, and Intervals 172
Booleans 172
Binary Data 172
ROWIDs 173
REF CURSORs 173
x | Table of Contents
Download at WoweBook.Com
Internet Datatypes 174
“Any” Datatypes 174
User-Defined Datatypes 174
Declaring Program Data 175
Declaring a Variable 175
Declaring Constants 176
The NOT NULL Clause 177
Anchored Declarations 177
Anchoring to Cursors and Tables 179
Benefits of Anchored Declarations 180
Anchoring to NOT NULL Datatypes 181
Programmer-Defined Subtypes 182
Conversion Between Datatypes 183
Implicit Data Conversion 183
Explicit Datatype Conversion 185
8. Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
String Datatypes 191
The VARCHAR2 Datatype 192
The CHAR Datatype 193
String Subtypes 194
Working with Strings 195
Specifying String Constants 195
Using Nonprintable Characters 197
Concatenating Strings 198
Dealing with Case 199
Traditional Searching, Extracting, and Replacing 202
Padding 204
Trimming 206
Regular Expression Searching, Extracting, and Replacing 207
Working with Empty Strings 218
Mixing CHAR and VARCHAR2 Values 219
String Function Quick Reference 222
9. Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Numeric Datatypes 231
The NUMBER Type 232
The PLS_INTEGER Type 237
The BINARY_INTEGER Type 238
The SIMPLE_INTEGER Type 239
The BINARY_FLOAT and BINARY_DOUBLE Types 241
The SIMPLE_FLOAT and SIMPLE_DOUBLE Types 246
Numeric Subtypes 246
Table of Contents | xi
Download at WoweBook.Com
Number Conversions 247
The TO_NUMBER Function 247
The TO_CHAR Function 251
The CAST Function 256
Implicit Conversions 257
Numeric Operators 259
Numeric Functions 260
Rounding and Truncation Functions 260
Trigonometric Functions 261
Numeric Function Quick Reference 261
10. Dates and Timestamps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Datetime Datatypes 267
Declaring Datetime Variables 270
Choosing a Datetime Datatype 271
Getting the Current Date and Time 272
Interval Datatypes 274
Declaring INTERVAL Variables 275
When to Use INTERVALs 276
Datetime Conversions 278
From Strings to Datetimes 279
From Datetimes to Strings 281
Working with Time Zones 284
Requiring a Format Mask to Match Exactly 287
Easing Up on Exact Matches 288
Interpreting Two-Digit Years in a Sliding Window 288
Converting Time Zones to Character Strings 290
Padding Output with Fill Mode 291
Date and Timestamp Literals 291
Interval Conversions 292
Converting from Numbers to Intervals 293
Converting Strings to Intervals 294
Formatting Intervals for Display 295
Interval Literals 295
CAST and EXTRACT 297
The CAST Function 297
The EXTRACT Function 299
Datetime Arithmetic 300
Date Arithmetic with Intervals and Datetimes 300
Date Arithmetic with DATE Datatypes 301
Computing the Interval Between Two Datetimes 302
Mixing DATEs and TIMESTAMPs 304
Adding and Subtracting Intervals 305
xii | Table of Contents
Download at WoweBook.Com
Multiplying and Dividing Intervals 306
Using Unconstrained INTERVAL Types 306
Date/Time Function Quick Reference 308
11. Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Records in PL/SQL 311
Benefits of Using Records 312
Declaring Records 314
Programmer-Defined Records 315
Working with Records 318
Comparing Records 325
Trigger Pseudo-Records 326
12. Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Collections Overview 328
Collections Concepts and Terminology 328
Types of Collections 330
Collection Examples 331
Where You Can Use Collections 335
Choosing a Collection Type 340
Collection Methods (Built-ins) 341
The COUNT Method 343
The DELETE Method 343
The EXISTS Method 345
The EXTEND Method 345
The FIRST and LAST Methods 346
The LIMIT Method 347
The PRIOR and NEXT Methods 348
The TRIM Method 349
Working with Collections 350
Declaring Collection Types 350
Declaring and Initializing Collection Variables 355
Populating Collections with Data 359
Accessing Data Inside a Collection 364
Using String-Indexed Collections 365
Collections of Complex Datatypes 370
Multilevel Collections 374
Working with Collections in SQL 382
Nested Table Multiset Operations 387
Testing Equality and Membership of Nested Tables 389
Checking for Membership of an Element in a Nested Table 390
Performing High-Level Set Operations 390
Handling Duplicates in a Nested Table 392
Table of Contents | xiii
Download at WoweBook.Com
Maintaining Schema-Level Collections 393
Necessary Privileges 393
Collections and the Data Dictionary 394
13. Miscellaneous Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
The BOOLEAN Datatype 395
The RAW Datatype 396
The UROWID and ROWID Datatypes 397
Getting ROWIDs 398
Using ROWIDs 398
The LOB Datatypes 400
Working with LOBs 401
Understanding LOB Locators 403
Empty Versus NULL LOBs 405
Writing into a LOB 407
Reading from a LOB 409
BFILEs Are Different 410
SecureFiles Versus BasicFiles 415
Temporary LOBs 417
Native LOB Operations 421
LOB Conversion Functions 425
Predefined Object Types 426
The XMLType Type 426
The URI Types 430
The Any Types 431
Part IV. SQL in PL/SQL
14. DML and Transaction Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
DML in PL/SQL 440
A Quick Introduction to DML 440
Cursor Attributes for DML Operations 444
RETURNING Information from DML Statements 445
DML and Exception Handling 446
DML and Records 447
Transaction Management 450
The COMMIT Statement 451
The ROLLBACK Statement 451
The SAVEPOINT Statement 452
The SET TRANSACTION Statement 453
The LOCK TABLE Statement 454
Autonomous Transactions 454
xiv | Table of Contents
Download at WoweBook.Com
Defining Autonomous Transactions 455
Rules and Restrictions on Autonomous Transactions 456
Transaction Visibility 457
When to Use Autonomous Transactions 458
Building an Autonomous Logging Mechanism 459
15. Data Retrieval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Cursor Basics 464
Some Data Retrieval Terms 465
Typical Query Operations 466
Introduction to Cursor Attributes 467
Referencing PL/SQL Variables in a Cursor 470
Choosing Between Explicit and Implicit Cursors 471
Working with Implicit Cursors 471
Implicit Cursor Examples 472
Error Handling with Implicit Cursors 473
Implicit SQL Cursor Attributes 476
Working with Explicit Cursors 477
Declaring Explicit Cursors 479
Opening Explicit Cursors 482
Fetching from Explicit Cursors 483
Column Aliases in Explicit Cursors 484
Closing Explicit Cursors 485
Explicit Cursor Attributes 487
Cursor Parameters 489
SELECT...FOR UPDATE 492
Releasing Locks with COMMIT 494
The WHERE CURRENT OF Clause 495
Cursor Variables and REF CURSORs 496
Why Cursor Variables? 497
Similarities to Static Cursors 498
Declaring REF CURSOR Types 498
Declaring Cursor Variables 499
Opening Cursor Variables 500
Fetching from Cursor Variables 501
Rules for Cursor Variables 504
Passing Cursor Variables as Arguments 507
Cursor Variable Restrictions 509
Cursor Expressions 509
Using Cursor Expressions 510
Restrictions on Cursor Expressions 512
Table of Contents | xv
Download at WoweBook.Com
16. Dynamic SQL and Dynamic PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
NDS Statements 514
The EXECUTE IMMEDIATE Statement 514
The OPEN FOR Statement 517
About the Four Dynamic SQL Methods 523
Binding Variables 525
Argument Modes 526
Duplicate Placeholders 527
Passing NULL Values 528
Working with Objects and Collections 529
Dynamic PL/SQL 531
Build Dynamic PL/SQL Blocks 532
Replace Repetitive Code with Dynamic Blocks 534
Recommendations for NDS 535
Use Invoker Rights for Shared Programs 535
Anticipate and Handle Dynamic Errors 536
Use Binding Rather Than Concatenation 538
Minimize the Dangers of Code Injection 540
When to Use DBMS_SQL 543
Parse Very Long Strings 543
Obtain Information About Query Columns 544
Meet Method 4 Dynamic SQL Requirements 546
Minimize Parsing of Dynamic Cursors 552
Oracle Database 11g New Features 554
DBMS_SQL.TO_REFCURSOR Function 554
DBMS_SQL.TO_CURSOR Function 556
Enhanced Security for DBMS_SQL 558
Part V. PL/SQL Application Construction
17. Procedures, Functions, and Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Modular Code 566
Procedures 567
Calling a Procedure 568
The Procedure Header 569
The Procedure Body 570
The END Label 570
The RETURN Statement 571
Functions 571
Structure of a Function 571
The RETURN Datatype 573
The END Label 575
xvi | Table of Contents
Download at WoweBook.Com
Calling a Function 575
Functions Without Parameters 576
The Function Header 577
The Function Body 577
The RETURN Statement 578
Parameters 579
Defining Parameters 580
Actual and Formal Parameters 581
Parameter Modes 582
Explicit Association of Actual and Formal Parameters in PL/SQL 585
The NOCOPY Parameter Mode Qualifier 589
Default Values 589
Local or Nested Modules 590
Benefits of Local Modularization 591
Scope of Local Modules 594
Sprucing Up Your Code with Local Modules 594
Module Overloading 595
Benefits of Overloading 596
Restrictions on Overloading 599
Overloading with Numeric Types 600
Forward Declarations 601
Advanced Topics 602
Calling Your Function From Inside SQL 602
Table Functions 605
Deterministic Functions 615
Go Forth and Modularize! 616
18. Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
Why Packages? 617
Demonstrating the Power of the Package 618
Some Package-Related Concepts 621
Diagramming Privacy 623
Rules for Building Packages 624
The Package Specification 624
The Package Body 626
Initializing Packages 627
Rules for Calling Packaged Elements 632
Working with Package Data 633
Global Within a Single Oracle Session 633
Global Public Data 634
Packaged Cursors 635
Serializable Packages 639
When to Use Packages 642
Table of Contents | xvii
Download at WoweBook.Com
Encapsulate Data Access 642
Avoid Hardcoding Literals 645
Improve Usability of Built-in Features 647
Group Together Logically Related Functionality 648
Cache Static Session Data 649
Packages and Object Types 650
19. Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651
DML Triggers 652
DML Trigger Concepts 653
Creating a DML Trigger 655
DML Trigger Example: No Cheating Allowed! 660
Multiple Triggers of the Same Type 665
Who Follows Whom 666
Mutating Table Errors 668
Compound Triggers: Putting It All In One Place 669
DDL Triggers 673
Creating a DDL Trigger 673
Available Events 676
Available Attributes 676
Working with Events and Attributes 678
Dropping the Undroppable 681
The INSTEAD OF CREATE Trigger 682
Database Event Triggers 683
Creating a Database Event Trigger 683
The STARTUP Trigger 685
The SHUTDOWN Trigger 685
The LOGON Trigger 685
The LOGOFF Trigger 686
The SERVERERROR Trigger 686
INSTEAD OF Triggers 690
Creating an INSTEAD OF Trigger 690
The INSTEAD OF INSERT Trigger 692
The INSTEAD OF UPDATE Trigger 694
The INSTEAD OF DELETE Trigger 695
Populating the Tables 695
INSTEAD OF Triggers on Nested Tables 696
AFTER SUSPEND Triggers 697
Setting Up for the AFTER SUSPEND Trigger 698
Looking at the Actual Trigger 700
The ORA_SPACE_ERROR_INFO Function 701
The DBMS_RESUMABLE Package 702
Trapped Multiple Times 703
xviii | Table of Contents
Download at WoweBook.Com
To Fix or Not to Fix? 704
Maintaining Triggers 705
Disabling, Enabling, and Dropping Triggers 705
Creating Disabled Triggers 706
Viewing Triggers 706
Checking the Validity of Triggers 707
20. Managing PL/SQL Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
Managing Code in the Database 710
Overview of Data Dictionary Views 711
Display Information About Stored Objects 712
Display and Search Source Code 713
Use Program Size to Determine Pinning Requirements 715
Obtain Properties of Stored Code 715
Analyze and Modify Trigger State Through Views 716
Analyze Argument Information 717
Analyze Identifier Usage (Oracle Database 11g’s PL/Scope) 719
Managing Dependencies and Recompiling Code 721
Analyzing Dependencies with Data Dictionary Views 722
Fine-Grained Dependency (Oracle Database 11g) 726
Remote Dependencies 727
Limitations of Oracle’s Remote Invocation Model 730
Recompiling Invalid Program Units 731
Compile-Time Warnings 735
A Quick Example 735
Enabling Compile-Time Warnings 736
Some Handy Warnings 738
Testing PL/SQL Programs 746
Typical, Tawdry Testing Techniques 747
General Advice for Testing PL/SQL Code 751
Automated Testing Options for PL/SQL 752
Testing with utPLSQL 753
Testing with Quest Code Tester for Oracle 755
Tracing PL/SQL Execution 756
DBMS_APPLICATION_INFO 759
Quest Error Manager Tracing 761
The DBMS_TRACE Facility 763
Debugging PL/SQL Programs 766
The Wrong Way to Debug 767
Debugging Tips and Strategies 769
Protecting Stored Code 774
Restrictions on and Limitations of Wrapping 774
Using the Wrap Executable 775
Table of Contents | xix
Download at WoweBook.Com
Dynamic Wrapping with DBMS_DDL 775
Guidelines for Working with Wrapped Code 776
Introduction to Edition-Based Redefinition (Oracle Database 11g Release
2) 777
21. Optimizing PL/SQL Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 781
Tools to Assist in Optimization 783
Analyzing Memory Usage 783
Identifying Bottlenecks in PL/SQL Code 783
Calculating Elapsed Time 788
Choosing the Fastest Program 790
Avoiding Infinite Loops 792
Performance-Related Warnings 793
The Optimizing Compiler 793
Insights on How the Optimizer Works 795
Runtime Optimization of Fetch Loops 798
Data Caching Techniques 799
Package-Based Caching 800
Deterministic Function Caching 805
Function Result Cache (Oracle Database 11g) 807
Caching Summary 819
Bulk Processing for Multirow SQL 820
High Speed Querying with BULK COLLECT 821
High Speed DML with FORALL 828
Improving Performance With Pipelined Table Functions 838
Replacing Row-Based Inserts with Pipelined Function-Based Loads 839
Tuning Merge Operations with Pipelined Functions 846
Asynchronous Data Unloading with Parallel Pipelined Functions 848
Performance Implications of Partitioning and Streaming Clauses in Parallel
Pipelined Functions 851
Pipelined Functions and the Cost-Based Optimizer 853
Tuning Complex Data Loads with Pipelined Functions 859
A Final Word on Pipelined Functions 866
Specialized Optimization Techniques 866
Using the NOCOPY Parameter Mode Hint 867
Using the Right Datatype 870
Stepping Back for the Big Picture on Performance 871
22. I/O and PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 873
Displaying Information 873
Enabling DBMS_OUTPUT 874
Write Lines to the Buffer 874
Read the Contents of the Buffer 875
xx | Table of Contents
Download at WoweBook.Com
Reading and Writing Files 876
The UTL_FILE_DIR Parameter 877
Work with Oracle Directories 879
Open Files 880
Is the File Already Open? 882
Close Files 882
Read from Files 883
Write to Files 885
Copy Files 888
Delete Files 889
Rename and Move Files 890
Retrieve File Attributes 890
Sending Email 891
Oracle Prerequisites 893
Configuring Network Security 893
Send a Short (32,767 or Less) Plaintext Message 894
Include “Friendly” Names in Email Addresses 896
Send a Plaintext Message of Arbitrary Length 897
Send a Message with a Short (< 32,767) Attachment 898
Send a Small File (< 32767) as an Attachment 900
Attach a File of Arbitrary Size 900
Working with Web-Based Data (HTTP) 903
Retrieve a Web Page in “Pieces” 903
Retrieve a Web Page into a LOB 905
Authenticate Using HTTP Username/Password 906
Retrieve an SSL-Encrypted Web Page (Via HTTPS) 906
Submit Data to a Web Page via GET or POST 908
Disable Cookies or Make Cookies Persistent 912
Retrieve Data from an FTP Server 912
Use a Proxy Server 913
Other Types of I/O Available in PL/SQL 913
Database Pipes, Queues, and Alerts 914
TCP Sockets 914
Oracle’s Built-in Web Server 914
Part VI. Advanced PL/SQL Topics
23. Application Security and PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 919
Security Overview 919
Encryption 921
Key Length 922
Algorithms 923
Table of Contents | xxi
Download at WoweBook.Com
Padding and Chaining 924
The DBMS_CRYPTO Package 925
Encrypting Data 926
Encrypting LOBs 929
SecureFiles 930
Decrypting Data 930
Performing Key Generation 932
Performing Key Management 932
Cryptographic Hashing 938
Using Message Authentication Codes 940
Using Transparent Data Encryption (TDE) 941
Transparent Tablespace Encryption 944
Row-Level Security 945
Why Learn About RLS? 947
A Simple RLS Example 949
Using Dynamic Policies 953
Using Column-Sensitive RLS 957
RLS Debugging 960
Application Contexts 964
Using Application Contexts 965
Security in Contexts 966
Contexts as Predicates in RLS 967
Identifying Non-Database Users 970
Fine-Grained Auditing 972
Why Learn About FGA? 973
A Simple FGA Example 974
Access How Many Columns? 976
Checking the Audit Trail 977
Using Bind Variables 978
Using Handler Modules 979
24. PL/SQL Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 981
Who (or What) is DIANA? 981
How Does Oracle Execute PL/SQL Code? 982
An Example 983
Compiler Limits 986
The Default Packages of PL/SQL 987
Execution Authority Models 990
The Definer Rights Model 990
The Invoker Rights Model 995
Combining Rights Models 997
Conditional Compilation 998
Examples of Conditional Compilation 999
xxii | Table of Contents
Download at WoweBook.Com
The Inquiry Directive 1000
The $IF Directive 1004
The $ERROR Directive 1005
Synchronizing Code with Packaged Constants 1006
Program-Specific Settings with Inquiry Directives 1006
Working with Postprocessed Code 1008
PL/SQL and Database Instance Memory 1009
PGA, UGA, and CGA 1010
Cursors, Memory, and More 1011
Tips on Reducing Memory Use 1013
What to Do if You Run Out of Memory 1024
Native Compilation 1027
When to Run Interpreted Mode 1027
When to Go Native 1028
Native Compilation and Database Release 1028
What You Need to Know 1029
25. Globalization and Localization in PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031
Overview and Terminology 1033
Unicode Primer 1034
National Character Set Datatypes 1036
Character Encoding 1036
Globalization Support Parameters 1037
Unicode Functions 1038
Character Semantics 1045
String Sort Order 1049
Binary Sort 1050
Monolingual Sort 1050
Multilingual Sort 1053
Multilingual Information Retrieval 1054
IR and PL/SQL 1056
Date/Time 1059
Timestamp Datatypes 1059
Date/Time Formatting 1060
Currency Conversion 1064
Globalization Development Kit for PL/SQL 1066
UTL_118N Utility Package 1066
UTL_LMS Error-Handling Package 1069
GDK Implementation Options 1070
26. Object-Oriented Aspects of PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1073
Introduction to Oracle’s Object Features 1073
Object Types by Example 1075
Table of Contents | xxiii
Download at WoweBook.Com
Creating a Base Type 1076
Creating a Subtype 1078
Methods 1079
Invoking Supertype Methods in Oracle Database 11g 1084
Storing, Retrieving, and Using Persistent Objects 1085
Evolution and Creation 1093
Back to Pointers? 1095
Generic Data: The ANY Types 1102
I Can Do It Myself 1106
Comparing Objects 1110
Object Views 1115
A Sample Relational System 1116
Object View with a Collection Attribute 1118
Object Subview 1121
Object View with Inverse Relationship 1122
INSTEAD OF Triggers 1123
Differences Between Object Views and Object Tables 1125
Maintaining Object Types and Object Views 1127
Data Dictionary 1127
Privileges 1128
Concluding Thoughts from a (Mostly) Relational Developer 1130
27. Calling Java from PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1133
Oracle and Java 1133
Getting Ready to Use Java in Oracle 1135
Installing Java 1135
Building and Compiling Your Java Code 1136
Setting Permissions for Java Development and Execution 1137
A Simple Demonstration 1139
Finding the Java Functionality 1140
Building a Custom Java Class 1140
Compiling and Loading into Oracle 1142
Building a PL/SQL Wrapper 1144
Deleting Files from PL/SQL 1145
Using loadjava 1146
Using dropjava 1148
Managing Java in the Database 1148
The Java Namespace in Oracle 1148
Examining Loaded Java Elements 1149
Using DBMS_JAVA 1150
LONGNAME: Converting Java Long Names 1151
GET_, SET_, and RESET_COMPILER_OPTION: Getting and Setting
(a Few) Compiler Options 1151
xxiv | Table of Contents
Download at WoweBook.Com
SET_OUTPUT: Enabling Output from Java 1152
EXPORT_SOURCE, EXPORT_RESOURCE, and EXPORT_CLASS:
Exporting Schema Objects 1153
Publishing and Using Java in PL/SQL 1155
Call Specs 1155
Some Rules for Call Specs 1157
Mapping Datatypes 1157
Calling a Java Method in SQL 1159
Exception Handling with Java 1160
Extending File I/O Capabilities 1163
Other Examples 1167
28. External Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1171
Introduction to External Procedures 1172
Example: Invoking an Operating System Command 1172
Architecture of External Procedures 1174
The Oracle Net Configuration 1176
Specifying the Listener Configuration 1176
Security Characteristics of the Configuration 1178
Setting Up Multithreaded Mode 1179
Creating an Oracle Library 1182
Writing the Call Specification 1183
The Call Spec: Overall Syntax 1184
Parameter Mapping: The Example Revisited 1186
Parameter Mapping: The Full Story 1188
More Syntax: The PARAMETERS Clause 1189
PARAMETERS Properties 1190
Raising an Exception from the Called C Program 1193
Nondefault Agents 1196
Maintaining External Procedures 1199
Dropping Libraries 1199
Data Dictionary 1200
Rules and Warnings 1200
A. Regular Expression Metacharacters and Function Parameters . . . . . . . . . . . . . . . 1203
B. Number Format Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1209
C. Date Format Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1213
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1219
2017-09-01
大型分布式网站架构设计与实践.带目录书签.完整版
大型分布式网站架构设计与实践.带目录书签.完整版
第1章 面向服务的体系架构(SOA)
第2章 分布式系统基础设施
第3章 互联网安全架构
。。。
2017-08-31
Java编程思想第四版完整中文高清版(免费).pdf
完整详实高清的Java编程思想四版
《THINKING IN JAVA》中文版.............................................................................................................................................1
写在前面的话 ..............................................................................................................................................................................6
引 言 ................................................................................................................................................................................................8
1. 前提......................................................................................................................................................................................8
2. Java 的学习.........................................................................................................................................................................8
3. 目标......................................................................................................................................................................................8
4. 联机文档.............................................................................................................................................................................9
5. 章节......................................................................................................................................................................................9
6. 练习....................................................................................................................................................................................12
7. 多媒体CD-ROM .............................................................................................................................................................12
8. 源代码................................................................................................................................................................................12
9. 编码样式...........................................................................................................................................................................14
10. Java 版本.........................................................................................................................................................................14
11. 课程和培训.....................................................................................................................................................................14
12. 错误..................................................................................................................................................................................14
13. 封面设计.........................................................................................................................................................................15
14. 致谢..................................................................................................................................................................................15
第 1 章对象入门.......................................................................................................................................................................27
1.1 抽象的进步.....................................................................................................................................................................27
1.2 对象的接口.....................................................................................................................................................................28
1.3 实现方案的隐藏............................................................................................................................................................29
1.4 方案的重复使用............................................................................................................................................................30
1.5 继承:重新使用接口...................................................................................................................................................30
1.5.1 改善基础类.............................................................................................................................................................. 30
1.5.2 等价与类似关系..................................................................................................................................................... 31
1.6 多形对象的互换使用...................................................................................................................................................31
1.6.1 动态绑定.................................................................................................................................................................. 32
1.6.2 抽象的基础类和接口............................................................................................................................................ 32
1.7 对象的创建和存在时间...............................................................................................................................................33
1.7.1 集合与继承器......................................................................................................................................................... 33
1.7.2 单根结构.................................................................................................................................................................. 34
1.7.3 集合库与方便使用集合........................................................................................................................................ 35
1.7.4 清除时的困境:由谁负责清除? ...................................................................................................................... 35
1.8 违例控制:解决错误...................................................................................................................................................36
1.9 多线程..............................................................................................................................................................................37
1.10 永久性...........................................................................................................................................................................37
1.11 Java 和因特网..............................................................................................................................................................37
1.11.1 什么是Web? ...................................................................................................................................................... 37
1.11.2 客户端编程(注释⑧) ..................................................................................................................................... 38
1.11.3 服务器端编程....................................................................................................................................................... 41
1.11.4 一个独立的领域:应用程序............................................................................................................................. 41
1.12 分析和设计...................................................................................................................................................................42
1.12.1 不要迷失................................................................................................................................................................ 42
1.12.2 阶段0:拟出一个计划....................................................................................................................................... 42
1.12.3 阶段1:要制作什么?....................................................................................................................................... 43
1.12.4 阶段2:如何构建? ........................................................................................................................................... 43
1.12.5 阶段3:开始创建............................................................................................................................................... 44
1.12.6 阶段4:校订........................................................................................................................................................ 44
1.12.7 计划的回报........................................................................................................................................................... 45
1.13 Java 还是C++?........................................................................................................................................................45
18
第2 章一切都是对象 ..............................................................................................................................................................46
2.1 用句柄操纵对象............................................................................................................................................................46
2.2 所有对象都必须创建...................................................................................................................................................46
2.2.1 保存到什么地方..................................................................................................................................................... 46
2.2.2 特殊情况:主要类型............................................................................................................................................ 47
2.2.3 Java 的数组............................................................................................................................................................. 48
2.3 绝对不要清除对象.......................................................................................................................................................48
2.3.1 作用域...................................................................................................................................................................... 48
2.3.2 对象的作用域......................................................................................................................................................... 49
2.4 新建数据类型:类.......................................................................................................................................................49
2.4.1 字段和方法.............................................................................................................................................................. 49
2.5 方法、自变量和返回值...............................................................................................................................................50
2.5.1 自变量列表.............................................................................................................................................................. 51
2.6 构建Java 程序...............................................................................................................................................................52
2.6.1 名字的可见性......................................................................................................................................................... 52
2.6.2 使用其他组件......................................................................................................................................................... 52
2.6.3 static 关键字............................................................................................................................................................ 52
2.7 我们的第一个Java 程序.............................................................................................................................................53
2.8 注释和嵌入文档............................................................................................................................................................55
2.8.1 注释文档.................................................................................................................................................................. 56
2.8.2 具体语法.................................................................................................................................................................. 56
2.8.3 嵌入HTML............................................................................................................................................................. 56
2.8.4 @see:引用其他类............................................................................................................................................... 57
2.8.5 类文档标记.............................................................................................................................................................. 57
2.8.6 变量文档标记......................................................................................................................................................... 57
2.8.7 方法文档标记......................................................................................................................................................... 57
2.8.8 文档示例.................................................................................................................................................................. 58
2.9 编码样式.........................................................................................................................................................................59
2.10 总结................................................................................................................................................................................59
2.11 练习................................................................................................................................................................................59
第 3 章控制程序流程 ..............................................................................................................................................................60
3.1 使用Java 运算符..........................................................................................................................................................60
3.1.1 优先级...................................................................................................................................................................... 60
3.1.2 赋值........................................................................................................................................................................... 60
3.1.3 算术运算符.............................................................................................................................................................. 62
3.1.4 自动递增和递减..................................................................................................................................................... 64
3.1.5 关系运算符.............................................................................................................................................................. 65
3.1.6 逻辑运算符.............................................................................................................................................................. 66
3.1.7 按位运算符.............................................................................................................................................................. 68
3.1.8 移位运算符.............................................................................................................................................................. 68
3.1.9 三元if-else 运算符................................................................................................................................................ 71
3.1.10 逗号运算符........................................................................................................................................................... 72
3.1.11 字串运算符+......................................................................................................................................................... 72
3.1.12 运算符常规操作规则.......................................................................................................................................... 72
3.1.13 造型运算符........................................................................................................................................................... 73
3.1.14 Java 没有“sizeof” ............................................................................................................................................ 74
3.1.15 复习计算顺序....................................................................................................................................................... 75
3.1.16 运算符总结........................................................................................................................................................... 75
3.2 执行控制.........................................................................................................................................................................84
3.2.1 真和假...................................................................................................................................................................... 84
3.2.2 if-else........................................................................................................................................................................ 84
3.2.3 反复........................................................................................................................................................................... 85
19
3.2.4 do-while.................................................................................................................................................................... 85
3.2.5 for.............................................................................................................................................................................. 86
3.2.6 中断和继续.............................................................................................................................................................. 87
3.2.7 开关........................................................................................................................................................................... 91
3.3 总结..................................................................................................................................................................................94
3.4 练习..................................................................................................................................................................................94
第 4 章初始化和清除 ..............................................................................................................................................................95
4.1 用构建器自动初始化...................................................................................................................................................95
4.2 方法过载.........................................................................................................................................................................96
4.2.1 区分过载方法......................................................................................................................................................... 97
4.2.2 主类型的过载......................................................................................................................................................... 98
4.2.3 返回值过载............................................................................................................................................................ 101
4.2.4 默认构建器............................................................................................................................................................ 102
4.2.5 this 关键字............................................................................................................................................................. 102
4.3 清除:收尾和垃圾收集............................................................................................................................................105
4.3.1 finalize()用途何在................................................................................................................................................ 105
4.3.2 必须执行清除....................................................................................................................................................... 106
4.4 成员初始化..................................................................................................................................................................108
4.4.1 规定初始化............................................................................................................................................................ 109
4.4.2 构建器初始化....................................................................................................................................................... 111
4.5 数组初始化..................................................................................................................................................................116
4.5.1 多维数组................................................................................................................................................................ 119
4.6 总结...............................................................................................................................................................................121
4.7 练习...............................................................................................................................................................................121
第 5 章隐藏实施过程 ...........................................................................................................................................................123
5.1 包:库单元..................................................................................................................................................................123
5.1.1 创建独一无二的包名.......................................................................................................................................... 124
5.1.2 自定义工具库....................................................................................................................................................... 126
5.1.3 利用导入改变行为.............................................................................................................................................. 128
5.1.4 包的停用................................................................................................................................................................ 130
5.2 Java 访问指示符........................................................................................................................................................130
5.2.1 “友好的”............................................................................................................................................................ 130
5.2.2 public:接口访问................................................................................................................................................ 131
5.2.3 private:不能接触!........................................................................................................................................... 132
5.2.4 protected:“友好的一种”.............................................................................................................................. 133
5.3 接口与实现..................................................................................................................................................................134
5.4 类访问...........................................................................................................................................................................135
5.5 总结...............................................................................................................................................................................136
5.6 练习...............................................................................................................................................................................137
第 6 章类再生 ........................................................................................................................................................................139
6.1 合成的语法..................................................................................................................................................................139
6.2 继承的语法..................................................................................................................................................................141
6.2.1 初始化基础类....................................................................................................................................................... 143
6.3 合成与继承的结合....................................................................................................................................................145
6.3.1 确保正确的清除................................................................................................................................................... 146
6.3.2 名字的隐藏............................................................................................................................................................ 148
6.4 到底选择合成还是继承............................................................................................................................................149
6.5 protected ....................................................................................................................................................................... 150
6.6 累积开发......................................................................................................................................................................151
6.7 上溯造型......................................................................................................................................................................151
6.7.1 何谓“上溯造型”?.......................................................................................................................................... 152
6.8 final 关键字..................................................................................................................................................................152
6.8.1 final 数据................................................................................................................................................................ 152
20
6.8.2 final 方法................................................................................................................................................................ 155
6.8.3 final 类.................................................................................................................................................................... 156
6.8.4 final 的注意事项.................................................................................................................................................. 156
6.9 初始化和类装载.........................................................................................................................................................157
6.9.1 继承初始化............................................................................................................................................................ 157
6.10 总结.............................................................................................................................................................................158
6.11 练习.............................................................................................................................................................................159
第 7 章多形性 ........................................................................................................................................................................160
7.1 上溯造型......................................................................................................................................................................160
7.1.1 为什么要上溯造型.............................................................................................................................................. 161
7.2 深入理解......................................................................................................................................................................162
7.2.1 方法调用的绑定................................................................................................................................................... 163
7.2.2 产生正确的行为................................................................................................................................................... 163
7.2.3 扩展性.................................................................................................................................................................... 165
7.3 覆盖与过载..................................................................................................................................................................168
7.4 抽象类和方法.............................................................................................................................................................169
7.5 接口...............................................................................................................................................................................172
7.5.1 Java 的“多重继承”.......................................................................................................................................... 174
7.5.2 通过继承扩展接口.............................................................................................................................................. 176
7.5.3 常数分组................................................................................................................................................................ 177
7.5.4 初始化接口中的字段.......................................................................................................................................... 178
7.6 内部类...........................................................................................................................................................................179
7.6.1 内部类和上溯造型.............................................................................................................................................. 180
7.6.2 方法和作用域中的内部类................................................................................................................................. 181
7.6.3 链接到外部类....................................................................................................................................................... 186
7.6.4 static 内部类.......................................................................................................................................................... 187
7.6.5 引用外部类对象................................................................................................................................................... 189
7.6.6 从内部类继承....................................................................................................................................................... 190
7.6.7 内部类可以覆盖吗?.......................................................................................................................................... 190
7.6.8 内部类标识符....................................................................................................................................................... 192
7.6.9 为什么要用内部类:控制框架......................................................................................................................... 192
7.7 构建器和多形性.........................................................................................................................................................198
7.7.1 构建器的调用顺序.............................................................................................................................................. 198
7.7.2 继承和finalize() ................................................................................................................................................... 199
7.7.3 构建器内部的多形性方法的行为.................................................................................................................... 202
7.8 通过继承进行设计....................................................................................................................................................204
7.8.1 纯继承与扩展....................................................................................................................................................... 205
7.8.2 下溯造型与运行期类型标识............................................................................................................................. 206
7.9 总结...............................................................................................................................................................................208
7.10 练习.............................................................................................................................................................................208
第 8 章对象的容纳 ................................................................................................................................................................209
8.1 数组...............................................................................................................................................................................209
8.1.1 数组和第一类对象.............................................................................................................................................. 209
8.1.2 数组的返回............................................................................................................................................................ 212
8.2 集合...............................................................................................................................................................................213
8.2.1 缺点:类型未知................................................................................................................................................... 213
8.3 枚举器(反复器) ....................................................................................................................................................217
8.4 集合的类型..................................................................................................................................................................220
8.4.1 Vector..................................................................................................................................................................... 220
8.4.2 BitSet...................................................................................................................................................................... 221
8.4.3 Stack ....................................................................................................................................................................... 222
8.4.4 Hashtable................................................................................................................................................................223
8.4.5 再论枚举器............................................................................................................................................................ 228
21
8.5 排序...............................................................................................................................................................................229
8.6 通用集合库..................................................................................................................................................................232
8.7 新集合...........................................................................................................................................................................233
8.7.1 使用Collections................................................................................................................................................... 235
8.7.2 使用Lists............................................................................................................................................................... 238
8.7.3 使用Sets ................................................................................................................................................................ 242
8.7.4 使用Maps.............................................................................................................................................................. 244
8.7.5 决定实施方案....................................................................................................................................................... 247
8.7.6 未支持的操作....................................................................................................................................................... 253
8.7.7 排序和搜索............................................................................................................................................................ 255
8.7.8 实用工具................................................................................................................................................................ 259
8.8 总结...............................................................................................................................................................................261
8.9 练习...............................................................................................................................................................................262
第 9 章违例差错控制 ...........................................................................................................................................................263
9.1 基本违例......................................................................................................................................................................263
9.1.1 违例自变量............................................................................................................................................................ 264
9.2 违例的捕获..................................................................................................................................................................264
9.2.1 try 块....................................................................................................................................................................... 264
9.2.2 违例控制器............................................................................................................................................................ 265
9.2.3 违例规范................................................................................................................................................................ 265
9.2.4 捕获所有违例....................................................................................................................................................... 266
9.2.5 重新“掷”出违例.............................................................................................................................................. 267
9.3 标准 Java 违例............................................................................................................................................................ 270
9.3.1 RuntimeException 的特殊情况......................................................................................................................... 270
9.4 创建自己的违例.........................................................................................................................................................271
9.5 违例的限制..................................................................................................................................................................274
9.6 用finally 清除.............................................................................................................................................................276
9.6.1 用finally 做什么.................................................................................................................................................. 277
9.6.2 缺点:丢失的违例.............................................................................................................................................. 279
9.7 构建器...........................................................................................................................................................................280
9.8 违例匹配......................................................................................................................................................................283
9.8.1 违例准则................................................................................................................................................................ 284
9.9 总结...............................................................................................................................................................................284
9.10 练习.............................................................................................................................................................................284
第 10 章JAVA IO 系统.........................................................................................................................................................285
10.1 输入和输出................................................................................................................................................................285
10.1.1 InputStream的类型........................................................................................................................................... 285
10.1.2 OutputStream的类型........................................................................................................................................ 286
10.2 增添属性和有用的接口.........................................................................................................................................286
10.2.1 通过FilterInputStream 从InputStream里读入数据................................................................................... 287
10.2.2 通过FilterOutputStream 向OutputStream 里写入数据............................................................................. 287
10.3 本身的缺陷:RandomAccessFile.........................................................................................................................288
10.4 File 类.........................................................................................................................................................................288
10.4.1 目录列表器......................................................................................................................................................... 288
10.4.2 检查与创建目录.................................................................................................................................................292
10.5 IO 流的典型应用......................................................................................................................................................294
10.5.1 输入流.................................................................................................................................................................. 296
10.5.2 输出流.................................................................................................................................................................. 298
10.5.3 快捷文件处理..................................................................................................................................................... 298
10.5.4 从标准输入中读取数据.................................................................................................................................... 300
10.5.5 管道数据流......................................................................................................................................................... 300
10.6 StreamTokenizer........................................................................................................................................................300
22
10.6.1 StringTokenizer .................................................................................................................................................. 303
10.7 Java 1.1 的IO 流......................................................................................................................................................305
10.7.1 数据的发起与接收............................................................................................................................................ 305
10.7.2 修改数据流的行为............................................................................................................................................ 306
10.7.3 未改变的类......................................................................................................................................................... 306
10.7.4 一个例子.............................................................................................................................................................. 307
10.7.5 重导向标准IO.................................................................................................................................................... 310
10.8 压缩.............................................................................................................................................................................311
10.8.1 用GZIP 进行简单压缩..................................................................................................................................... 311
10.8.2 用Zip 进行多文件保存.................................................................................................................................... 312
10.8.3 Java 归档(jar)实用程序............................................................................................................................... 314
10.9 对象序列化................................................................................................................................................................315
10.9.1 寻找类.................................................................................................................................................................. 318
10.9.2 序列化的控制..................................................................................................................................................... 319
10.9.3 利用“持久性”.................................................................................................................................................326
10.10 总结...........................................................................................................................................................................332
10.11 练习...........................................................................................................................................................................332
第 11 章运行期类型鉴定.....................................................................................................................................................333
11.1 对RTTI 的需要.........................................................................................................................................................333
11.1.1 Class 对象............................................................................................................................................................ 334
11.1.2 造型前的检查..................................................................................................................................................... 337
11.2 RTTI 语法...................................................................................................................................................................342
11.3 反射:运行期类信息..............................................................................................................................................343
11.3.1 一个类方法提取器............................................................................................................................................ 344
11.4 总结.............................................................................................................................................................................347
11.5 练习.............................................................................................................................................................................348
第 12 章传递和返回对象.....................................................................................................................................................349
12.1 传递句柄....................................................................................................................................................................349
12.1.1 别名问题.............................................................................................................................................................. 349
12.2 制作本地副本...........................................................................................................................................................351
12.2.1 按值传递.............................................................................................................................................................. 351
12.2.2 克隆对象.............................................................................................................................................................. 352
12.2.3 使类具有克隆能力............................................................................................................................................ 353
12.2.4 成功的克隆......................................................................................................................................................... 353
12.2.5 Object.clone()的效果........................................................................................................................................ 355
12.2.6 克隆合成对象..................................................................................................................................................... 356
12.2.7 用Vector 进行深层复制................................................................................................................................... 358
12.2.8 通过序列化进行深层复制............................................................................................................................... 359
12.2.9 使克隆具有更大的深度.................................................................................................................................... 361
12.2.10 为什么有这个奇怪的设计............................................................................................................................. 362
12.3 克隆的控制................................................................................................................................................................363
12.3.1 副本构建器......................................................................................................................................................... 366
12.4 只读类........................................................................................................................................................................369
12.4.1 创建只读类......................................................................................................................................................... 370
12.4.2 “一成不变”的弊端........................................................................................................................................ 371
12.4.3 不变字串.............................................................................................................................................................. 373
12.4.4 String 和StringBuffer 类.................................................................................................................................. 374
12.4.5 字串的特殊性..................................................................................................................................................... 376
12.5 总结.............................................................................................................................................................................376
12.6 练习.............................................................................................................................................................................376
第十三 章创建窗口和程序片 ..............................................................................................................................................378
13.1 为何要用AWT ?......................................................................................................................................................378
23
13.2 基本程序片................................................................................................................................................................379
13.2.1 程序片的测试..................................................................................................................................................... 380
13.2.2 一个更图形化的例子........................................................................................................................................ 381
13.2.3 框架方法的演示.................................................................................................................................................381
13.3 制作按钮....................................................................................................................................................................382
13.4 捕获事件....................................................................................................................................................................382
13.5 文本字段....................................................................................................................................................................384
13.6 文本区域....................................................................................................................................................................385
13.7 标签.............................................................................................................................................................................386
13.8 复选框........................................................................................................................................................................387
13.9 单选钮........................................................................................................................................................................388
13.10 下拉列表..................................................................................................................................................................389
13.11 列表框......................................................................................................................................................................390
13.11.1 handleEvent() .................................................................................................................................................... 391
13.12 布局的控制.............................................................................................................................................................393
13.12.1 FlowLayout....................................................................................................................................................... 393
13.12.2 BorderLayout .................................................................................................................................................... 393
13.12.3 GridLayout........................................................................................................................................................ 394
13.12.4 CardLayout........................................................................................................................................................ 394
13.12.5 GridBagLayout.................................................................................................................................................396
13.13 action 的替代品......................................................................................................................................................396
13.14 程序片的局限.........................................................................................................................................................400
13.14.1 程序片的优点................................................................................................................................................... 401
13.15 视窗化应用.............................................................................................................................................................401
13.15.1 菜单.................................................................................................................................................................... 401
13.15.2 对话框................................................................................................................................................................ 404
13.16 新型AWT ................................................................................................................................................................. 408
13.16.1 新的事件模型................................................................................................................................................... 409
13.16.2 事件和接收者类型.......................................................................................................................................... 410
13.16.3 用Java 1.1 AWT制作窗口和程序片.......................................................................................................... 414
13.16.4 再研究一下以前的例子................................................................................................................................. 416
13.16.5 动态绑定事件................................................................................................................................................... 431
13.16.6 将事务逻辑与UI 逻辑区分开...................................................................................................................... 433
13.16.7 推荐编码方法................................................................................................................................................... 435
13.17 Java 1.1 用户接口API..........................................................................................................................................448
13.17.1 桌面颜色........................................................................................................................................................... 448
13.17.2 打印.................................................................................................................................................................... 448
13.17.3 剪贴板................................................................................................................................................................ 454
13.18 可视编程和Beans.................................................................................................................................................456
13.18.1 什么是Bean...................................................................................................................................................... 457
13.18.2 用Introspector 提取BeanInfo....................................................................................................................... 458
13.18.3 一个更复杂的Bean ........................................................................................................................................ 463
13.18.4 Bean 的封装...................................................................................................................................................... 465
13.18.5 更复杂的Bean 支持........................................................................................................................................ 466
13.18.6 Bean 更多的知识............................................................................................................................................. 466
13.19 Swing 入门(注释⑦).........................................................................................................................................467
13.19.1 Swing 有哪些优点........................................................................................................................................... 467
13.19.2 方便的转换....................................................................................................................................................... 467
13.19.3 显示框架........................................................................................................................................................... 468
13.19.4 工具提示..................................................................
2011-11-19
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人