Contact Management App stores every contact as aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/efrain-svg/Potes_Freddy_ProgInterfacesG_U3/llms.txt
Use this file to discover all available pages before exploring further.
persona object in memory and persists the contact list as a semicolon-delimited CSV file on disk. This page documents the persona entity—its fields, constructors, and serialization methods—and the personaDAO data-access object that manages the CSV file.
persona fields
| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
nombre | String | Yes | "" | Contact’s full name. Trimmed and null-guarded by limpiar(). |
telefono | String | Yes | "" | Phone number stored as a string to preserve leading zeros and formatting. |
email | String | Yes | "" | Email address. |
categoria | String | Yes | "" | One of the three category codes: FAMILY, FRIENDS, or WORK. |
favorito | boolean | No | false | Whether the contact is marked as a favourite. |
fechaRegistro | LocalDate | No | today | Date the contact was first added. Set to LocalDate.now() when not supplied. |
All string fields pass through the private
limpiar(String) method, which trims whitespace and converts null to an empty string. This prevents malformed CSV lines caused by accidental null values.Constructors
persona.java
personaDAO.leerArchivo() when reconstructing contacts from the 6-column CSV format. The standard constructor is used when the user creates a new contact through the UI.
Serialization methods
datosContacto() — CSV serialization
Returns a semicolon-delimited string suitable for appending to the CSV file:
persona.java
NOMBRE;TELEFONO;EMAIL;CATEGORIA;FAVORITO;FECHA_REGISTRO.
comoFilaTabla() — JTable row
Returns an Object[] that the controller inserts directly into the DefaultTableModel:
persona.java
fechaRegistro is not shown in the table but is preserved in the in-memory persona object and written back to disk on every save.
Category codes
The application uses three stable category codes internally. Display names are provided in three languages and mapped to codes bypersonaDAO.normalizarCategoria().
| Code | Spanish | English | Portuguese |
|---|---|---|---|
FAMILY | Familia | Family | Família |
FRIENDS | Amigos | Friends | Amigos |
WORK | Trabajo | Work | Trabalho |
CSV file format
The contact list is stored at a fixed location:personaDAO.prepararArchivo() creates both the directory and the file with its header row if they do not yet exist.
Current format (6 columns)
datosContactos.csv
Legacy format (5 columns)
Files written by earlier versions of the application omit theFECHA_REGISTRO column:
datosContactos.csv (legacy)
Backward compatibility
leerArchivo() detects the number of columns in each data row and handles both formats:
personaDAO.java
CSV escaping
Values are written with RFC 4180 escaping viaarmarLineaCsv(String[]) and escaparCsv(String):
- Fields containing the separator (
;), double quotes ("), or newlines are wrapped in double quotes. - Existing double-quote characters inside a field are escaped as
"".
personaDAO method reference
| Method | Access | Signature | Description |
|---|---|---|---|
| Constructor | public | personaDAO(persona) | Initializes the DAO with the contact to operate on and sets the file path. |
escribirArchivo | public | boolean escribirArchivo() | Appends the current persona to the CSV file. Returns false if persona is null. |
leerArchivo | public | List<persona> leerArchivo() throws IOException | Reads the entire file, skips the header and blank lines, parses 5- or 6-column rows, normalizes categories. |
actualizarContactos | public | void actualizarContactos(List<persona>) throws IOException | Rewrites the entire CSV file from a provided list (used for edits and deletes). |
exportarCsv (default) | public | void exportarCsv(File, List<persona>) | Exports contacts to a user-chosen file using the default header row. |
exportarCsv (custom) | public | void exportarCsv(File, String[], List<String[]>) | Exports with caller-supplied column headers and pre-formatted row data. |
prepararArchivo | private | void prepararArchivo() | Creates the directory and file with header if they do not exist. Called from constructor. |
normalizarCategoria | private | String normalizarCategoria(String) | Maps a multilingual display name to a category code (FAMILY/FRIENDS/WORK). |
armarLineaCsv | private | String armarLineaCsv(String[]) | Joins an array of values into a semicolon-delimited line with RFC 4180 escaping. |
escaparCsv | private | String escaparCsv(String) | Wraps and escapes a single field value per RFC 4180. |
Related pages
Architecture overview
Package structure, technology stack, and key design decisions.
MVC pattern implementation
How the view exposes components and how the controller wires events.