How jhy/jsoup works
Main Components
a) Core API Layer
• Entry point (Jsoup.java)
• Connection interfaces
• Main public interfaces
b) Processing Layers
• Parser Layer
• DOM Layer
• Selection Layer
• Safety Layer
Component Details and Relationships
a) Input/Interface Layer:
• HTTP Connection handling (Connection.java, HttpConnection.java)
• Document input methods (URL, String, File)
b) Parser Component:
• Parser.java as the central component
• To subcomponents:
• Tokeniser
• TreeBuilder (both HTML and XML variants)
• CharacterReader
c) DOM Structure:
• Center around Document.java and Element.java
• Hierarchy of Node types:
• Elements
• TextNodes
• Comments
• DataNodes
• Use inheritance relationships
d) Selection/Query Layer:
• Selector.java as main component
• To:
• QueryParser
• Evaluator hierarchy
• Elements collection
e) Safety/Cleaning Layer:
• Cleaner.java
• Safelist.java
• As a separate but connected module
Specific Implementation Details
Key relationships:
[Input Sources] → [Connection API] → [Parser]
• ↓
[Selector Engine] ← [DOM Structure] ← [TreeBuilder]
• ↓
• [Elements Collection]
• ↓
• [Safety Cleaner]
Notes Section
Notes about:
• Thread safety considerations
• Memory management
• Performance characteristics
• Extension points
Remember to emphasize the library's key features:
• HTML parsing
• DOM manipulation
• CSS selection
• Safety cleaning
• URL fetching
This will provide a clear understanding of jsoup's architecture while maintaining the appropriate level of detail for a principal software engineer to understand both the high-level structure and important implementation details.