-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Design Smell: Multifaceted Abstraction
- Loading branch information
Kavya Bhojani
committed
Apr 1, 2024
1 parent
276f627
commit 4fc3e04
Showing
6 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
csv/src/main/java/com/fasterxml/jackson/dataformat/csv/ControlEscapeStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.fasterxml.jackson.dataformat.csv; | ||
|
||
import com.fasterxml.jackson.core.io.CharacterEscapes; | ||
|
||
public class ControlEscapeStrategy implements EscapeStrategy { | ||
@Override | ||
public int[] getEscapeCodesForAscii() { | ||
int[] escapes = CharacterEscapes.standardAsciiEscapesForJSON(); | ||
escapes['"'] = 0; // Do not escape double quotes. | ||
return escapes; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
csv/src/main/java/com/fasterxml/jackson/dataformat/csv/ControlQuoteEscapeStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.fasterxml.jackson.dataformat.csv; | ||
|
||
import com.fasterxml.jackson.core.io.CharacterEscapes; | ||
|
||
public class ControlQuoteEscapeStrategy implements EscapeStrategy { | ||
@Override | ||
public int[] getEscapeCodesForAscii() { | ||
return CharacterEscapes.standardAsciiEscapesForJSON(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
csv/src/main/java/com/fasterxml/jackson/dataformat/csv/EscapeStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fasterxml.jackson.dataformat.csv; | ||
|
||
public interface EscapeStrategy { | ||
int[] getEscapeCodesForAscii(); | ||
} |
9 changes: 9 additions & 0 deletions
9
csv/src/main/java/com/fasterxml/jackson/dataformat/csv/NoEscapeStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.fasterxml.jackson.dataformat.csv; | ||
|
||
public class NoEscapeStrategy implements EscapeStrategy | ||
{ | ||
@Override | ||
public int[] getEscapeCodesForAscii() { | ||
return new int[0]; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
csv/src/main/java/com/fasterxml/jackson/dataformat/csv/QuoteEscapeStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.fasterxml.jackson.dataformat.csv; | ||
|
||
public class QuoteEscapeStrategy implements EscapeStrategy { | ||
@Override | ||
public int[] getEscapeCodesForAscii() { | ||
int[] escapes = new int['"' + 1]; | ||
escapes['"'] = '"'; | ||
return escapes; | ||
} | ||
} |