package examples
- Alphabetic
- Public
- Protected
Deprecated Type Members
- case class Format(color: String, language: String, aspectRatio: Option[Double], duration: Option[Int]) extends Product with Serializable
Represents the format attributes associated with a movie, such as its color, language, aspect ratio, and duration.
Represents the format attributes associated with a movie, such as its color, language, aspect ratio, and duration. This case class is immutable and provides a concise way to model format details.
The
Formatcase class includes the following fields: -color(String): The color scheme of the movie (e.g., "Color", "Black and White"). -language(String): The language in which the movie is produced (e.g., "English", "French"). -aspectRatio(Option[Double]): An optional field representing the aspect ratio of the movie's visuals, which is expressed as a decimal (e.g.,1.85,2.35). If not provided, this field isNone. -duration(Option[Int]): An optional field representing the length of the movie in minutes. If not provided, this field isNone.The
toStringmethod of theFormatclass provides a comma-separated string representation of its field values, includingOptionfields, which are displayed asNonewhen not defined.- color
the color scheme of the movie's visuals.
- language
the primary language of the movie.
- aspectRatio
an optional aspect ratio for the movie's visuals.
- duration
an optional runtime of the movie in minutes. Usage example:
val format = Format("Color", "English", Some(1.85), Some(120)) println(format) // Outputs: Color,English,Some(1.85),Some(120) val defaultFormat = Format("", "", None, None) println(defaultFormat) // Outputs: ,,,None,None
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- case class Movie(title: String, format: Format, production: Production, reviews: Reviews, director: Principal, actor1: Principal, actor2: Principal, actor3: Option[Principal], genres: AttributeSet, plotKeywords: AttributeSet, imdb: String) extends Product with Serializable
The
Moviecase class represents a comprehensive set of data about a movie, including its title, format, production details, reviews, cast information, genres, plot keywords, and IMDb identifier.The
Moviecase class represents a comprehensive set of data about a movie, including its title, format, production details, reviews, cast information, genres, plot keywords, and IMDb identifier. It encapsulates essential and optional attributes about a movie in a structured format for easy parsing, manipulation, and serialization (e.g., CSV generation).- title
The title of the movie, represented as a string.
- format
The format details of the movie, as a
Formatobject. This includes information such as color, language, aspect ratio, and duration.- production
The production details of the movie, as a
Productionobject. This includes attributes such as country, budget, gross earnings, and title year.- reviews
The reviews and aggregated feedback data for the movie, as a
Reviewsobject. It includes IMDb score, social metrics, and review counts.- director
The director of the movie, represented as a
Principalobject, which includes the director's name and Facebook likes.- actor1
The first main actor in the movie, represented as a
Principalobject.- actor2
The second main actor in the movie, represented as a
Principalobject.- actor3
The third main actor in the movie, represented as an optional
Principalobject. If no third actor is present, this will beNone.- genres
The list of genres for the movie, represented as an
AttributeSet. This may include genres like Action, Drama, Comedy, etc.- plotKeywords
The set of plot-related keywords for the movie, represented as an
AttributeSet. Keywords provide insights into the movie's storyline.- imdb
The unique IMDb identifier for the movie, represented as a string.
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- case class Name(first: String, middle: Option[String], last: String, suffix: Option[String]) extends Product with Serializable
A case class representing a person's name with optional middle name and suffix.
A case class representing a person's name with optional middle name and suffix.
- first
The first name of the person (mandatory).
- middle
An optional middle name of the person.
- last
The last name (or family name) of the person (mandatory).
- suffix
An optional suffix, such as "Jr.", "Sr.", or other titles. The
Nameclass overrides thetoStringmethod to provide a concatenated string representation of the full name. The full name includes the first name, optionally followed by the middle name, then the last name, and finally an optional suffix. Components are separated by a space. Example usage:val fullName = Name("John", Some("William"), "Doe", Some("Jr.")) println(fullName.toString) // Output: "John William Doe Jr." val simpleName = Name("Jane", None, "Smith", None) println(simpleName.toString) // Output: "Jane Smith"
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- case class Principal(name: Name, facebookLikes: Int) extends Product with Serializable
Represents a principal entity involved in a production.
Represents a principal entity involved in a production. This entity is characterized by its name and the number of Facebook likes it has received. Typically, the
Principalclass is used to model contributors such as actors, directors, or other individuals associated with a movie or production.- name
the
Nameinstance representing the principal's full name, which includes fields for the first name, middle name (optional), last name, and suffix (optional).- facebookLikes
the number of Facebook likes associated with the principal, which can serve as a measure of the individual's popularity or reach on social media.
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
val principal = Principal(Name("John", Some("A."), "Doe", None), 1200) println(principal) // Output: John A. Doe (1200 likes)
- Note
The
Principalclass is part of a broader model for describing movies or productions, and may be used in conjunction with other classes such asMovieorProduction. Additionally, a default instance ofPrincipalmay be provided in an accompanying companion object for known default values.
Example: - case class Production(country: String, budget: Option[Int], gross: Option[Int], titleYear: Option[Int]) extends Product with Serializable
The
Productioncase class represents the metadata associated with a creative production, such as a film, including its country of origin, budget, gross revenue, and release year.The
Productioncase class represents the metadata associated with a creative production, such as a film, including its country of origin, budget, gross revenue, and release year.Fields
- country
the country where the production originated, as a non-null
String.- budget
an optional
Intrepresenting the production's budget. If unavailable, it isNone.- gross
an optional
Intrepresenting the total gross revenue of the production. If unavailable, it isNone.- titleYear
an optional
Intrepresenting the year the production was released or titled. If unavailable, it isNone.Methods
isKiwi: Determines if the production originates from New Zealand.
Usage Example
val production1 = Production("New Zealand", Some(1500000), Some(5000000), Some(2022)) val production2 = Production("USA", None, None, None) println(production1.isKiwi) // Output: true println(production2.isKiwi) // Output: false
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- case class Rating(code: String, age: Option[Int]) extends Product with Serializable
Represents a content rating, typically used to signify the suitability of media content (e.g., movies, shows) for different audiences.
Represents a content rating, typically used to signify the suitability of media content (e.g., movies, shows) for different audiences. The
Ratingclass consists of a code (e.g., "PG", "R", "G") and an optional age specification (e.g., "PG-13").- code
The code representing the general content rating (e.g., "PG", "R").
- age
An optional integer specifying the age restriction for the content, if applicable (e.g., a value of
13for "PG-13").
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- case class Reviews(imdbScore: Double, facebookLikes: Int, contentRating: Rating, numUsersReview: Option[Int], numUsersVoted: Int, numCriticReviews: Option[Int], totalFacebookLikes: Int) extends Product with Serializable
The
Reviewscase class represents aggregated review and user feedback data for a movie, encapsulating information such as IMDb scores, social media metrics, content rating, and review counts.The
Reviewscase class represents aggregated review and user feedback data for a movie, encapsulating information such as IMDb scores, social media metrics, content rating, and review counts.- imdbScore
The IMDb score of the movie, typically ranging from 1 to 10 with up to one decimal place.
- facebookLikes
The number of likes the movie has on Facebook, used as a measure of its popularity on the platform.
- contentRating
The
Ratingobject indicating the content rating of the movie (e.g., PG, R), which may also include age restrictions.- numUsersReview
An
Optionrepresenting the number of user reviews submitted for the movie. A value ofNoneindicates an unknown or unavailable count.- numUsersVoted
The total number of users who voted for the movie on IMDb.
- numCriticReviews
An
Optionrepresenting the number of critic reviews submitted for the movie. A value ofNoneindicates an unknown or unavailable count.- totalFacebookLikes
The total combined Facebook likes of the movie's cast and crew, providing a broader measure of social media presence.
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
Deprecated Value Members
- object Format extends CellParsers with CsvGenerators with CsvRenderers with Serializable
The
Formatobject provides a predefined constant for representing a defaultFormatinstance.The
Formatobject provides a predefined constant for representing a defaultFormatinstance. It serves as a utility object for commonly used instances of theFormatcase class.The default format instance (
none) is initialized with empty orNonevalues for fields, representing a situation where no specific format details are available.- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- See also
Format The case class representing the format attributes such as color, language, aspect ratio, and duration.
- object Movie extends CellParsers with CsvGenerators with CsvRenderers with Serializable
The
Movieobject provides functionality for generating CSV representations ofMovieinstances.The
Movieobject provides functionality for generating CSV representations ofMovieinstances. It utilizes theCsvGeneratorsframework to define and create CSV generators for the various fields and nested components of theMovieclass, as well as theMovieclass itself.Overview
The
Movieobject contains the following key elements:- **csvGenerators**: An instance of
CsvGeneratorsthat provides predefined CSV generators for standard data types such asBoolean,Int,Double, andString. It serves as the foundation for custom CSV generators.- **createMovieCvsGenerator**: A method that constructs a
CsvGeneratorspecific to theMovieclass. This generator supports serialization ofMovieinstances into CSV format, accounting for nested data structures and optional values.Dependencies
This object imports the following from
com.phasmidsoftware.tableparser.core.render.CsvGenerators: - Predefined implicit CSV generators for basic data types and utilities for creating additional generators.Key Method Descriptions
-
createMovieCvsGenerator:- Constructs and returns a
CsvGenerator[Movie], facilitating the generation of CSV rows forMovieobjects. - Custom generators are defined for various components of the
Movieclass, including:StringList: A sequence of strings.Option[Double]: OptionalDoublevalues.Option[Int]: OptionalIntvalues.Option[String]: OptionalStringvalues.Format: A case class representing the format of aMovie.Production: A case class holding details about aMovie's production.Rating: Represents a case class for the rating information of aMovie.Reviews: A case class containing detailed review information.Name: A case class for principal names.Principal: A case class for individuals associated with aMovie.Option[Principal]: An optionalPrincipal.AttributeSet: A case class for sets of attributes such as genres or plot keywords.
- The resulting
CsvGenerator[Movie]aggregates these component-level generators to enable CSV serialization of the entireMovieobject.
Usage
To generate a CSV representation of
Movieobjects: 1. Invoke thecreateMovieCvsGeneratormethod within this object to obtain the appropriateCsvGenerator[Movie]. 2. Use the generatedCsvGeneratorto serialize aMovieinstance into a CSV format.This utility is especially useful for exporting
Moviedata into a structured format, such as for persistence or integration with external systems that require CSV data.Example
val movieCsvGenerator = Movie.createMovieCvsGenerator val movie = Movie("Inception", Format(...), Production(...), Reviews(...), ...) val csvRepresentation = movieCsvGenerator.generate(movie)
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- Constructs and returns a
- object Name extends CellParsers with CsvGenerators with CsvRenderers with Serializable
Companion object for the
Namecase class, providing factory methods for parsing strings intoNameinstances.Companion object for the
Namecase class, providing factory methods for parsing strings intoNameinstances.This object handles the parsing of a formatted name string (e.g., "John A. Smith Jr.") into its respective components: first name, middle name/initial, last name, and optional suffix. It uses a regular expression to perform this parsing and validates the input.
Regex Pattern
The internal regular expression (
rName) is designed to match and extract components of a name. While it works for most typical name formats, some complex or unconventional names in certain datasets (e.g., the Movie database) might not be parsed correctly. The components matched by the regex are:- First Name (mandatory)
- Middle Name/Initial (optional)
- Last Name (mandatory)
- Suffix (optional)
Factory Methods
The apply method is overloaded to:
- Parse a single string into a
Nameinstance. - Throw an exception if the input string does not conform to the expected format.
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
val name1 = Name("John Smith") // Name("John", None, "Smith", None) val name2 = Name("John A. Smith") // Name("John", Some("A."), "Smith", None) val name3 = Name("John Smith Jr.") // Name("John", None, "Smith", Some("Jr.")) val name4 = Name("John A. Smith Jr.") // Name("John", Some("A."), "Smith", Some("Jr.")) // An invalid name format will throw an exception val invalidName = Name("John") // throws Exception: parse error in Name: 'John'
Usage in Context
The
Nameclass and object are primarily used in parsing movie-related data structures and rendering them to/from CSVs:- The
createMovieCvsGeneratormethod usesName.applyto generate CSV entries forNameinstances. - Rendering movie-related data via
CsvRendererMovieinvolves therendererNamegenerator, built aroundName.
- The
- Note
The
Namecase class has a corresponding customtoStringimplementation for formatted string representation.
Example: - object Principal extends CellParsers with CsvGenerators with CsvRenderers with Serializable
Companion object for the
Principalcase class, providing default values and utility objects related to principal entities in a production context.Companion object for the
Principalcase class, providing default values and utility objects related to principal entities in a production context.This object currently includes a predefined default instance:
nemo: The defaultPrincipalinstance with a defaultName("ne mo") andfacebookLikesvalue of 0.
Usage
The
Principalobject, along with its case class, is typically used to represent individuals such as actors, directors, or contributors in a production database system, with information about their name and popularity metrics.Predefined Instance
nemo: A convenient defaultPrincipalinstance, used as a placeholder or fallback.
- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
Using the default
Principal:println(Principal.nemo) // Output: ne mo (0 likes)Relation
Works in conjunction with the
Principalcase class and is associated with other models in parsing, processing, and rendering movie-related data structures.
Example: - object Production extends CellParsers with CsvGenerators with CsvRenderers with Serializable
The
Productionobject serves as a companion object for theProductioncase class.The
Productionobject serves as a companion object for theProductioncase class. It provides predefined constants and utility methods related to the concept of a production, such as a film or other creative work.Overview
- The
Productionobject includes commonly used instances of theProductionclass. - It facilitates operations on and interactions withProductionobjects in a consistent manner.- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- See also
Production case class for the associated data structure and detailed behavior.
- object Rating extends CellParsers with CsvGenerators with CsvRenderers with Serializable
Companion object for the
Ratingcase class.Companion object for the
Ratingcase class. This object provides utility methods to constructRatinginstances and to parse rating strings intoRating.- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0
- object Reviews extends CellParsers with CsvGenerators with CsvRenderers with Serializable
The
Reviewsobject contains utility members and predefined instances related to theReviewscase class.The
Reviewsobject contains utility members and predefined instances related to theReviewscase class.This object is primarily used to define default or placeholder instances of
Reviews, such as thenonevalue, which represents aReviewsinstance with default or empty data.- Annotations
- @deprecated
- Deprecated
(Since version 1.7.0) Example code: it moves out of the library, into the tests, in 2.0.0